﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.OracleClient;
using ReflectionStudio.Core.Events;
namespace WPFExcelReport
{

    public class GreigeMasterData : BaseFunction
    {
        public GreigeMasterData()
            : base()
        {

        }
        public GreigeMasterData(OracleConnection _OracleDB, IntexReptServBLClient _proxy, string userID = "        ")
            : base(_OracleDB, _proxy, userID)
        {

        }
        public DataSet LoadTableStructure(DataSet dsTarget)
        {
            try
            {
                TableQueue.Enqueue("WAFARBEN");
                TableQueue.Enqueue("SELECT WAFART as ArtNum,	WAFVAR as ArtVar,	 WAFZUSATZ as ArtColor,WAFBEZ as ColorDescription"
                    + "  FROM INTEX.WAFARBEN WHERE RowNum<1");
                TableQueue.Enqueue("BSSATZ");
                TableQueue.Enqueue("SELECT  "
                    + "BSKART"
                    + ",BSFDZ"
                    + ",BSSRFNR"
                    + ",BSFAKTOR"
                   + " FROM INTEX.BSSATZ WHERE RowNum<1");
                TableQueue.Enqueue("BASTKE");
                TableQueue.Enqueue("SELECT "
                              + "BAKART"
               + ",BAKVAR"
               + ",BAKFARBE"
               + ",BAKKART"
               + ",BAKKVAR"
               + ",BAKKFARBE"
               + ",BAKPATT"
               + ",BAKPOS"
               + ",BAKANZ"
               + ",BAKABF"
               + " FROM INTEX.BASTKE WHERE RowNum<1");
                TableQueue.Enqueue("BSFARB");
                TableQueue.Enqueue("SELECT  "
                    + "BSFKART"
                    + ",BSFKVAR"
                    + ",BSFKFARBE "
                    + ",BSFBEZ"
                + " FROM INTEX.BSFARB WHERE RowNum<1");
                TableQueue.Enqueue("BASTGA");
                TableQueue.Enqueue("SELECT "
                + "BAGFDZ"
                + ",BAGART"
                + ",BAGVAR"
                + ",BAGFARBE"
                + ",BAGPOS"
                + ",BAGGART"
                + ",BAGGVAR"
                + ",BAGGFARBE"
                + ",BAGFDZ"
                + ",BAGKGNET"
                + ",BAGKGBRUT"
                + " FROM INTEX.BASTGA WHERE RowNum<1");
                TableQueue.Enqueue("WASTGA");
                TableQueue.Enqueue("SELECT  "
                       + "WAGART"
                + ",WAGVAR"
                + ",WAGWCOL"
                + ",WAGPSA"
                + ",WAGPOS"
                + ",WAGGART"
                + ",WAGGVAR"
                + ",WAGGFARBE"
                + ",WAGFDZ"
                + ",WAGKGNET"
                + ",WAGKGBRUT"
                + ",WAGEAFAKTOR"
                + ",WAGBEM"
                + " FROM INTEX.WASTGA WHERE RowNum<1");
                TableQueue.Enqueue("GSDAT");
                TableQueue.Enqueue("SELECT "
                + " GSART"
                + " ,GSVAR"
                + " ,GSMAT"
                + " ,GSNUMART"
                + " ,GSGARNNR"
                + " ,GSFACH"
                + " ,GSRECHNUM"
                + " ,GSRECHNR"
                 + " FROM INTEX.GSDAT WHERE RowNum<1");
                TableQueue.Enqueue("GASTGA");
                TableQueue.Enqueue("SELECT "
                    + "GAGART"
                    + ",GAGVAR"
                    + ",GAGFARBE"
                    + ",GAGPOS"
                    + ",GAGGART"
                    + ",GAGGVAR"
                    + ",GAGGFARBE"
                    + ",GAGKGNET"
                    + ",GAGKGBRUT"
                   + " FROM INTEX.GASTGA Where RowNum<1");
                TableQueue.Enqueue("GSCOLOR");
                TableQueue.Enqueue("SELECT GSCART,GSCVAR,GSCFARBE,GSCBEZ FROM INTEX.GSCOLOR WHERE RowNum<1");
                while (TableQueue.Count > 0)
                {
                    string TableName = TableQueue.Dequeue() as string;
                    string QueryStr = TableQueue.Dequeue() as string;
                    if (!dsTarget.Tables.Contains(TableName))
                    {
                        orlReadCommand = OracleDB.CreateCommand();
                        orlReadCommand.CommandText = QueryStr;
                        dsResult = Connect2Proxy(orlReadCommand);
                        if (dsResult.Tables.Count > 0)
                        {
                            dsResult.Tables[0].TableName = TableName;
                        }
                        foreach (DataTable dtTemp in dsResult.Tables)
                        {
                            dsTarget = ImportDataTable(dsTarget, dtTemp);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return dsTarget;
        }
        public GreigeMasterData(Dictionary<string, object> DicGlobalPara)
            : base(DicGlobalPara)
        {
        }
        public DataSet GetGreigeMaster(DataSet dsTarget, DataRow dwWAFARBEN)
        {
            try
            {
                #region WASTAMM
                orlReadCommand = OracleDB.CreateCommand();
                orlReadCommand.CommandText = "SELECT WAART " +
                ",WAVAR" +
                ",WAAENB" +
                ",WAPROGRP" +
                ",WAARTGRP" +
                ",WARSTAKZ" +
                ",WAVWART" +
                ",WAVWVAR" +
                ",WAFFDDIK" +
                ",WAFFDDIS" +
                ",WAFDDIM" +
                ",WARFDDIK" +
                ",WARFDDIS" +
                ",WAFBRTL" +
                ",WARWBRT" +
                ",WAFGRQM" +
                ",WARGRQM" +
                ",WAFGRLFD" +
                ",WARGRLFD" +
                ",WABIND" +
                ",WAEINZNR" +
                ",WARSTDLG" +
                ",WARSTDGW" +
                ",WARFDDIS" +
                ",WALAEAEND as FEnlongation" +
                ",WATEXTE1" +
                ",WATEXTE2" +
                ",WATEXTE3" +
                ",WANEUB,WANEUD,WAAENB,WAAEND" +
                ", WAART as ComEN" +
                ", WAART as ComCN" +
                " FROM INTEX.WASTAMM WHERE WAART =:ArticleNum AND WAVAR=:ArticleVar";
                orlReadCommand.Parameters.Add("ArticleNum", OracleType.NVarChar).Value = dwWAFARBEN["WAFART"].ToString();
                orlReadCommand.Parameters.Add("ArticleVar", OracleType.NVarChar).Value = dwWAFARBEN["WAFVAR"].ToString();
                dsResult = Connect2Proxy(orlReadCommand);

                if (dsResult.Tables.Count > 0)
                {
                    dsResult.Tables[0].TableName = "WASTAMM";
                    Queue Q10 = new Queue();
                    Q10.Enqueue("WAFBRTL");
                    Q10.Enqueue("WARWBRT");
                    Queue Q100 = new Queue();
                    Q100.Enqueue("WAFFDDIK");
                    Q100.Enqueue("WAFFDDIS");
                    Q100.Enqueue("WARFDDIK");
                    Q100.Enqueue("WARFDDIS");
                    Q100.Enqueue("FEnlongation");
                    Queue Q1000 = new Queue();
                    Q1000.Enqueue("WARSTDLG");
                    Q1000.Enqueue("WARSTDGW");

                    DivideBy10(dsResult.Tables[0], Q10);
                    DivideBy100(dsResult.Tables[0], Q100);
                    DivideBy1000(dsResult.Tables[0], Q1000);

                }
                DataTable dtWASTAMM = dsResult.Tables["WASTAMM"];
                foreach (DataRow dwWASTAMM in dtWASTAMM.Rows)
                {
                    string WATEXTE1 = dwWASTAMM["WATEXTE1"].ToString();
                    dwWASTAMM["WATEXTE1"] = GetCommentsFromTXTIND("WKT", WATEXTE1);
                    string WATEXTE2 = dwWASTAMM["WATEXTE2"].ToString();
                    dwWASTAMM["WATEXTE2"] = GetCommentsFromTXTIND("WKT", WATEXTE2);
                    string WATEXTE3 = dwWASTAMM["WATEXTE3"].ToString();
                    dwWASTAMM["WATEXTE3"] = GetCommentsFromTXTIND("WKT", WATEXTE3);
                }
                #endregion

                #region Compostion
                string ArticleNum = dwWAFARBEN["WAFART"].ToString();
                string ArticleVar = dwWAFARBEN["WAFVAR"].ToString();
                orlReadCommand = OracleDB.CreateCommand();
                orlReadCommand.CommandText = "SELECT STUELISAPD,STUELIPPOS as POS,STUELISASB as COM, STUELISASB as CNName, STUELIDATEN as Portion " +
                " FROM INTEX.STUELI WHERE STUELISAPD like '%" +
                ArticleNum + "%" +
                ArticleVar + "%'";

                dsResult = Connect2Proxy(orlReadCommand);

                if (dsResult.Tables.Count > 0)
                {
                    dsResult.Tables[0].TableName = "WSCOMPOSITION";

                }

                DataTable dtWSCOM = dsResult.Tables["WSCOMPOSITION"];
                string Client = "00";
                string Lang = "V";
                string COM = "";
                string strCom = "                     ";//22
                string POS = "";
                string CNName = "";
                double Portion = 0.0;
                string ComEN = "";
                string ComCN = "";


                foreach (DataRow dsWSCOM in dtWSCOM.Rows)
                {
                    POS = dsWSCOM["POS"].ToString();
                    COM = dsWSCOM["COM"].ToString();
                    CNName = Client + (COM + strCom).Substring(0, 21) + Lang;
                    CNName = GetDataFromSDDAT("0013", CNName);
                    dsWSCOM["CNName"] = CNName;
                    Portion = System.Convert.ToDouble(dsWSCOM["Portion"].ToString().Substring(0, 4)) / 10.00;
                    ComEN += COM.TrimEnd() + Math.Round(Portion, 2).ToString().Trim() + "%  ";
                    ComCN += CNName + Math.Round(Portion, 2).ToString().Trim() + "%  ";
                }
                if (dtWASTAMM.Rows.Count > 0)
                {
                    dtWASTAMM.Rows[0]["ComEN"] = ComEN;
                    dtWASTAMM.Rows[0]["ComCN"] = ComCN;
                }
                dsTarget = ImportDataTable(dsTarget, dtWASTAMM);
                //dsTarget = ImportDataTable(dsTarget, dtTemp);  
                #endregion
                //select * from STUELI where rownum<10 and STUELISAPD like '%PV912102            A1 %'


            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return dsTarget;
        }
        public DataTable GetGreigeColorWay(DataTable dtTarget, DataRow dwWAFARBEN)
        {
            try
            {
                orlReadCommand = OracleDB.CreateCommand();
                orlReadCommand.CommandText = "SELECT WAFART as ArtNum,	WAFVAR as ArtVar,	 WAFZUSATZ as ArtColor,WAFBEZ as ColorDes"
                    + ",WAFAENDBEN,WAFAENDDAT,WAFNEUBEN,WAFNEUDAT  FROM INTEX.WAFARBEN WHERE WAFART = :ArticleNum AND WAFVAR=:ArticleVar AND WAFZUART='C' AND WAFSTATUS='A'";
                orlReadCommand.Parameters.Add("ArticleNum", OracleType.NVarChar).Value = dwWAFARBEN["WAFART"].ToString();
                orlReadCommand.Parameters.Add("ArticleVar", OracleType.NVarChar).Value = dwWAFARBEN["WAFVAR"].ToString();
                dsResult = Connect2Proxy(orlReadCommand);
                if (dsResult.Tables.Count > 0)
                {
                    dsResult.Tables[0].TableName = "ARTICLECOLOR";
                    dtTarget = dsResult.Tables[0];
                    dsResult.AcceptChanges();
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return dtTarget;
        }
        public DataTable GetGreigeFinish(DataTable dtTarget, DataRow dwWAFARBEN)
        {
            try
            {

                orlReadCommand = OracleDB.CreateCommand();
                orlReadCommand.CommandText = "SELECT WAFART as ArtNum,	WAFVAR as ArtVar,	 WAFZUSATZ as ArtFin,WAFBEZ as FinishDes,WAFAENDBEN,WAFAENDDAT,WAFNEUBEN,WAFNEUDAT"
    + "  FROM INTEX.WAFARBEN WHERE WAFART = :ArticleNum AND WAFVAR=:ArticleVar AND WAFZUART='B' AND WAFSTATUS='A'";
                orlReadCommand.Parameters.Add("ArticleNum", OracleType.NVarChar).Value = dwWAFARBEN["WAFART"].ToString();
                orlReadCommand.Parameters.Add("ArticleVar", OracleType.NVarChar).Value = dwWAFARBEN["WAFVAR"].ToString();
                dsResult = Connect2Proxy(orlReadCommand);
                if (dsResult.Tables.Count > 0)
                {
                    dsResult.Tables[0].TableName = "ARTICLEFINISH";
                    dtTarget = dsResult.Tables["ARTICLEFINISH"];
                    dsResult.AcceptChanges();
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return dtTarget;
        }
        public DataTable GetGreigeVariant(DataTable dtTarget, DataRow dwWAFARBEN)
        {
            try
            {
                orlReadCommand = OracleDB.CreateCommand();
                orlReadCommand.CommandText = "SELECT WAVAR as ArtVar "
                    + "  FROM INTEX.WASTAMM WHERE WAART = :ArticleNum";
                orlReadCommand.Parameters.Add("ArticleNum", OracleType.NVarChar).Value = dwWAFARBEN["WAFART"].ToString();
                dsResult = Connect2Proxy(orlReadCommand);
                if (dsResult.Tables.Count > 0)
                {
                    dsResult.Tables[0].TableName = "ARTICLEVAR";
                    dtTarget = dsResult.Tables[0];
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return dtTarget;
        }
        public DataSet GetGreigeColorWay(DataSet dsTarget, DataRow dwWAFARBEN)
        {
            try
            {
                OracleCommand or1;
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT WAFART, WAFVAR,WAFZUART,WAFZUSATZ,WAFZUSATZ as WAFCOLORIT,'' as COMS,WAFAENDBEN,WAFAENDDAT,WAFNEUBEN,WAFNEUDAT" +
                    " FROM INTEX.WAFARBEN WHERE WAFART = :WAFART AND WAFVAR=:WAFVAR AND WAFZUSATZ=:WAFZUSATZ AND WAFSTATUS='A'";

                or1.Parameters.Add("WAFART", OracleType.NVarChar).Value = dwWAFARBEN["WAFART"].ToString();
                or1.Parameters.Add("WAFVAR", OracleType.NVarChar).Value = dwWAFARBEN["WAFVAR"].ToString();
                or1.Parameters.Add("WAFZUSATZ", OracleType.NVarChar).Value = dwWAFARBEN["WAFZUSATZ"].ToString();
                dsResult = Connect2Proxy(or1);
                if (dsResult.Tables.Count > 0)
                {
                    dsResult.Tables[0].TableName = "WAFARBEN";
                }
                foreach (DataRow rowWAFARBEN in dsResult.Tables["WAFARBEN"].Rows)
                {
                    DataSet setUI = new DataSet();
                    try
                    {

                        string COMMENTS = "";
                        orlReadCommand = OracleDB.CreateCommand();
                        orlReadCommand.CommandText = "SELECT trim(TXTKTEXT) AS COMS "
                            + " FROM TXTIND A,TXTKON B WHERE A.TXTIMANDANT = B.TXTKMANDANT "
                            + " AND A.TXTIPIND = B.TXTKPIND AND B.TXTKPOS >40 AND A.TXTITXTART = 'WAE' "
                            + " AND SUBSTR(A.TXTISIND,15,20) = :ArticleNum "
                            + " AND SUBSTR(A.TXTISIND,35,2)= :ArticleVar AND SUBSTR(A.TXTISIND,37,1)='C' "
                            + " AND SUBSTR(A.TXTISIND,38,10) = :ArticleColor ";
                        orlReadCommand.Parameters.Add("ArticleNum", OracleType.NVarChar).Value = rowWAFARBEN["WAFART"].ToString();
                        orlReadCommand.Parameters.Add("ArticleVar", OracleType.NVarChar).Value = rowWAFARBEN["WAFVAR"].ToString();
                        orlReadCommand.Parameters.Add("ArticleColor", OracleType.NVarChar).Value = rowWAFARBEN["WAFZUSATZ"].ToString();
                        setUI = Connect2Proxy(orlReadCommand);

                        if (setUI.Tables.Count > 0)
                        {
                            setUI.Tables[0].TableName = "WAFARBENCOMS";
                            foreach (DataRow rowTemp1 in setUI.Tables["WAFARBENCOMS"].Rows)
                            {

                                COMMENTS += rowTemp1["COMS"].ToString() + Environment.NewLine;
                            }
                        }
                        if (COMMENTS != "")
                        {
                            rowWAFARBEN["COMS"] = COMMENTS;
                        }
                    }
                    catch (Exception ex)
                    {
                        Tracer.Error(ex.StackTrace, ex);
                    }
                }
                foreach (DataTable dtTemp in dsResult.Tables)
                {
                    if (dsTarget.Tables.Contains("WAFARBEN"))
                    {
                        dsTarget.Tables["WAFARBEN"].Clear();
                        dsTarget.AcceptChanges();
                    }
                    dsTarget = ImportDataTable(dsTarget
                   , FilterByColor(dsResult.Tables["WAFARBEN"],
                   "WAFZUSATZ",
                   dwWAFARBEN["WAFZUSATZ"].ToString()));
                }
                dsTarget.Merge(dsResult);

            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return dsTarget;
        }
        public DataSet GetWarpBeamKey(DataSet dsTarget, DataRow dwWAFARBEN)
        {
            try
            {
                ///
                orlReadCommand = OracleDB.CreateCommand();
                orlReadCommand.CommandText = "SELECT  " +
                    "WAKART" +
                ",WAKWCOL" +
                ",WAKPOS" +
                ",WAKKART" +
                ",WAKKVAR" +
                ",WAKKFARBE" +
                ",WAKEAFAKTR" +
                ",WAKLLEIST" +
                ",WAKRLEIST" +
                    " FROM INTEX.WASTKE WHERE WAKART = :WAKART AND WAKVAR=:WAKVAR AND WAKWCOL=:WAKWCOL";
                orlReadCommand.Parameters.Add("WAKART", OracleType.NVarChar).Value = dwWAFARBEN["WAFART"].ToString();
                orlReadCommand.Parameters.Add("WAKVAR", OracleType.NVarChar).Value = dwWAFARBEN["WAFVAR"].ToString();
                orlReadCommand.Parameters.Add("WAKWCOL", OracleType.NVarChar).Value = dwWAFARBEN["WAFZUSATZ"].ToString();
                dsResult = Connect2Proxy(orlReadCommand);
                if (dsResult.Tables.Count > 0)
                {
                    dsResult.Tables[0].TableName = "WASTKE";
                    Queue Q1000 = new Queue();
                    Q1000.Enqueue("WAKEAFAKTR");
                    DivideBy1000(dsResult.Tables[0], Q1000);
                    /*
                    dsTarget = ImportDataTable(dsTarget
                   , FilterByColor(
                   dsResult.Tables["WASTKE"],
                   "WAKWCOL",
                   dwWAFARBEN["WAFZUSATZ"].ToString())*/
                    dsTarget.Merge(dsResult);
                }

            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return dsTarget;
        }
        public DataSet GetWeftYarn(DataSet dsTarget, DataRow dwWAFARBEN)
        {
            try
            {

                orlReadCommand = OracleDB.CreateCommand();
                orlReadCommand.CommandText = "SELECT  "
                       + "WAGART"
                + ",WAGVAR"
                + ",WAGWCOL"
                + ",WAGPSA"
                + ",WAGPOS"
                + ",WAGFOLGEPOS"
                + ",WAGGART"
                + ",WAGGVAR"
                + ",WAGGFARBE"
                + ",WAGFDZ"
                    + ",WAGABF"
                + ",WAGKGNET"
                + ",WAGKGBRUT"
                + ",WAGEAFAKTOR"
                + ",WAGBEM"
                + " FROM INTEX.WASTGA WHERE WAGPSA='1' AND WAGPOS='00' AND WAGART = :WAGART AND WAGVAR=:WAGVAR  AND WAGWCOL=:WAGWCOL";
                orlReadCommand.Parameters.Add("WAGART", OracleType.NVarChar).Value = dwWAFARBEN["WAFART"].ToString();
                orlReadCommand.Parameters.Add("WAGVAR", OracleType.NVarChar).Value = dwWAFARBEN["WAFVAR"].ToString();
                orlReadCommand.Parameters.Add("WAGWCOL", OracleType.NVarChar).Value = dwWAFARBEN["WAFZUSATZ"].ToString();
                dsResult = Connect2Proxy(orlReadCommand);
                if (dsResult.Tables.Count > 0)
                {
                    dsResult.Tables[0].TableName = "WASTGA";
                    Queue Q1000 = new Queue();
                    Q1000.Enqueue("WAGKGNET");
                    Q1000.Enqueue("WAGKGBRUT");
                    DivideBy1000(dsResult.Tables[0], Q1000);
                    Queue Q100 = new Queue();
                    Q100.Enqueue("WAGABF");
                    DivideBy100(dsResult.Tables[0], Q100);
                    dsTarget.Merge(dsResult);
                    /*
                    dsTarget = ImportDataTable(dsTarget,
                    FilterByColor(
                    dsResult.Tables["WASTGA"]
                    , "WAGWCOL"
                    , dwWAFARBEN["WAFZUSATZ"].ToString()));
                    */
                }

            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return dsTarget;
        }
        public DataSet GetTechnicalData(DataSet dsTarget, DataRow dwWAFARBEN)
        {
            try
            {
                orlReadCommand = OracleDB.CreateCommand();
                orlReadCommand.CommandText = "SELECT WTGART" +
                    ",WTGVAR" +
                    ",WTGWBBRT" +
                    ",WTGWBBRT-30 as InnerReed" +
                    ",WTGWBF" +
                    ",WTGFDISM" +
                    ",WTGFDLGS" +
                    ",WTGFDLFS" +
                    ",WTGSFLG" +
                    ",WTGKCOL" +
                    ",WTGSMTRS" +
                    " FROM INTEX.WTGEW WHERE WTGART = :ArticleNum AND WTGVAR=:ArticleVar";
                orlReadCommand.Parameters.Add("ArticleNum", OracleType.NVarChar).Value = dwWAFARBEN["WAFART"].ToString();
                orlReadCommand.Parameters.Add("ArticleVar", OracleType.NVarChar).Value = dwWAFARBEN["WAFVAR"].ToString();
                dsResult = Connect2Proxy(orlReadCommand);
                if (dsResult.Tables.Count > 0)
                {
                    dsResult.Tables[0].TableName = "WTGEW";
                    Queue Q10 = new Queue();
                    Q10.Enqueue("WTGWBBRT");
                    Q10.Enqueue("InnerReed");
                    Q10.Enqueue("WTGFDLGS");
                    Q10.Enqueue("WTGFDLFS");
                    Queue Q100 = new Queue();
                    Q100.Enqueue("WTGWBF");
                    Q100.Enqueue("WTGFDISM");
                    Q100.Enqueue("WTGSMTRS");
                    DivideBy10(dsResult.Tables[0], Q10);
                    DivideBy100(dsResult.Tables[0], Q100);
                }
                foreach (DataTable dtTemp in dsResult.Tables)
                {
                    dsTarget = ImportDataTable(dsTarget, dtTemp);
                }

            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return dsTarget;
        }
        public DataSet GetPatternKey(DataSet dsTarget, DataRow dwWAFARBEN)
        {
            try
            {
                // 
                orlReadCommand = OracleDB.CreateCommand();
                orlReadCommand.CommandText = "SELECT * FROM INTEX.WASTPASS WHERE WSPART = :ArticleNum AND WSPVAR=:ArticleVar";
                orlReadCommand.Parameters.Add("ArticleNum", OracleType.NVarChar).Value = dwWAFARBEN["WAFART"].ToString();
                orlReadCommand.Parameters.Add("ArticleVar", OracleType.NVarChar).Value = dwWAFARBEN["WAFVAR"].ToString();
                dsResult = Connect2Proxy(orlReadCommand);
                if (dsResult.Tables.Count > 0)
                {
                    dsResult.Tables[0].TableName = "WASTPASS";
                }
                foreach (DataTable dtTemp in dsResult.Tables)
                {
                    dsTarget = ImportDataTable(dsTarget, dtTemp);
                }

            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return dsTarget;
        }
        public DataSet BuildGreigeMasterData(DataSet dsTarget, DataRow dwWAFARBEN)
        {
            try
            {
                dsTarget = GetGreigeMaster(dsTarget, dwWAFARBEN);

                dwWAFARBEN["WAFART"] = dsTarget.Tables["WASTAMM"].Rows[0]["WAVWART"];
                dwWAFARBEN["WAFVAR"] = dsTarget.Tables["WASTAMM"].Rows[0]["WAVWVAR"];
                dsTarget = GetGreigeColorWay(dsTarget, dwWAFARBEN);
                dsTarget = GetTechnicalData(dsTarget, dwWAFARBEN);
                dsTarget = GetPatternKey(dsTarget, dwWAFARBEN);
                dsTarget = GetWarpBeamKey(dsTarget, dwWAFARBEN);
                dsTarget = GetWeftYarn(dsTarget, dwWAFARBEN);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return dsTarget;
        }

        #region ----------------EDIT-------------------------
        public void ComputeWeftQuantity(DataRow dwWASTAMM, DataRow dwWTGEW, ref DataRow dwWASTGA)
        {
            DataSet setReturn = new DataSet();
            DataSet setResult = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            string weftPattern = "", GSVAR, GSART, GSRECHNUM;
            double CountYarn, WAGFDZ, WTSSRAPP, WARSTDLG, WARFDDIS, in2cm, lenYarn, WTGFDLGS, mt2cm, mtr2yd, GSRECHNR, pound2kg, WAGABF, WAGKGNET, WAGKGBRUT;
            in2cm = 2.54;
            mt2cm = 100.00;
            mtr2yd = 0.9144;
            pound2kg = 0.4536;
            try
            {
                WAGFDZ = System.Convert.ToDouble(dwWASTGA["WAGFDZ"].ToString());
                WARSTDLG = System.Convert.ToDouble(dwWASTAMM["WARSTDLG"].ToString()) * 0.001;
                WARFDDIS = System.Convert.ToDouble(dwWASTAMM["WARFDDIS"].ToString()) * 0.01;
                WTGFDLGS = System.Convert.ToDouble(dwWTGEW["WTGFDLGS"].ToString()) * 0.1;
                GSART = dwWASTGA["WAGGART"].ToString();
                GSVAR = Left(dwWASTGA["WAGGVAR"].ToString() + "   ", 3);
                or1.CommandText = "SELECT * FROM GSDAT WHERE GSMANDANT='00' AND GSART='" + GSART + "' AND GSVAR='" + GSVAR + "'";
                setResult = Connect2Proxy(or1);
                if (setResult.Tables.Count == 0)
                {
                    return;
                }
                GSRECHNUM = setResult.Tables[0].Rows[0]["GSRECHNUM"].ToString();
                GSRECHNR = System.Convert.ToDouble(setResult.Tables[0].Rows[0]["GSRECHNR"].ToString()) * 0.0001;
                GSRECHNR = TONE(GSRECHNR, GSRECHNUM.Trim());
                weftPattern = dwWTGEW["WTGSFLG"].ToString();
                or1.CommandText = "SELECT * FROM WTSCHUSS WHERE WTSMANDANT='00' AND WTSSFLGNR='" + weftPattern + "'";
                setResult = Connect2Proxy(or1);
                if (setResult.Tables[0].Rows.Count == 0)
                {
                    Tracer.Info("ComputeWeftQuantity", "请验证花型是否存在");
                    return;
                }
                WTSSRAPP = System.Convert.ToDouble(setResult.Tables[0].Rows[0]["WTSSRAPP"].ToString());
                CountYarn = ((WAGFDZ / WTSSRAPP) * WARSTDLG * 100 * WARFDDIS) / in2cm;
                lenYarn = CountYarn * WTGFDLGS / mt2cm;
                WAGKGNET = (lenYarn / mtr2yd) / (GSRECHNR * 840) * pound2kg;
                WAGKGNET = System.Math.Round(WAGKGNET * 1000, 0);
                dwWASTGA["WAGKGNET"] = WAGKGNET.ToString().Replace(".0", "");
                WAGABF = System.Convert.ToDouble(dwWASTGA["WAGABF"].ToString()) * 0.01 * 0.01;
                WAGKGBRUT = WAGKGNET * (1 + WAGABF);
                WAGKGBRUT = System.Math.Round(WAGKGBRUT, 0);
                dwWASTGA["WAGKGBRUT"] = WAGKGBRUT.ToString().Replace(".0", "");
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        public DataSet GetRWS0305(DataRow dwWAFARBEN)
        {
            DataSet setReturn = new DataSet();
            DataSet setResult = new DataSet();
            try
            {
                DataTable tbLocal = null;
                #region WASTAMM
                orlReadCommand = OracleDB.CreateCommand();
                orlReadCommand.CommandText = "SELECT *  FROM INTEX.WASTAMM WHERE WAART =:ArticleNum AND WAVAR=:ArticleVar";
                orlReadCommand.Parameters.Add("ArticleNum", OracleType.NVarChar).Value = dwWAFARBEN["WAFART"].ToString();
                orlReadCommand.Parameters.Add("ArticleVar", OracleType.NVarChar).Value = dwWAFARBEN["WAFVAR"].ToString();
                setResult = Connect2Proxy(orlReadCommand);
                if (setResult.Tables.Count > 0)
                {
                    tbLocal = setResult.Tables[0];
                    tbLocal.TableName = "WASTAMM";
                }
                #endregion
                setReturn.Merge(setResult);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        }
        public DataSet GetRWS07(DataRow dwWAFARBEN, string WAFZUART, string WAFZUSATZ)
        {
            DataSet setReturn = new DataSet();
            DataSet setResult = new DataSet();
            try
            {
                orlReadCommand = OracleDB.CreateCommand();
                orlReadCommand.CommandText = "SELECT * FROM INTEX.WAFARBEN WHERE WAFART = :WAFART AND WAFVAR=:WAFVAR AND WAFZUART=:WAFZUART AND WAFZUSATZ=:WAFZUSATZ ";
                //AND WAFZUSATZ=:ArticleColor";
                orlReadCommand.Parameters.Add("WAFART", OracleType.NVarChar).Value = dwWAFARBEN["WAFART"].ToString();
                orlReadCommand.Parameters.Add("WAFVAR", OracleType.NVarChar).Value = dwWAFARBEN["WAFVAR"].ToString();
                orlReadCommand.Parameters.Add("WAFZUART", OracleType.NVarChar).Value = WAFZUART;
                orlReadCommand.Parameters.Add("WAFZUSATZ", OracleType.NVarChar).Value = WAFZUSATZ;

                setResult = Connect2Proxy(orlReadCommand);
                if (setResult.Tables.Count > 0)
                {
                    setResult.Tables[0].TableName = "WAFARBEN";
                }
                setReturn.Merge(setResult);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        }
        public DataSet GetRWTGEW(DataRow dwWAFARBEN)
        {
            DataSet setReturn = new DataSet();
            DataSet setResult = new DataSet();
            DataTable tbWTGEW = setINTEX.WTGEW.Clone();
            setReturn.Merge(tbWTGEW);
            try
            {
                orlReadCommand = OracleDB.CreateCommand();
                orlReadCommand.CommandText = "SELECT * FROM INTEX.WTGEW WHERE WTGART = :ArticleNum AND WTGVAR=:ArticleVar";
                orlReadCommand.Parameters.Add("ArticleNum", OracleType.NVarChar).Value = dwWAFARBEN["WAFART"].ToString();
                orlReadCommand.Parameters.Add("ArticleVar", OracleType.NVarChar).Value = dwWAFARBEN["WAFVAR"].ToString();
                setResult = Connect2Proxy(orlReadCommand);
                if (setResult.Tables.Count > 0)
                {
                    setResult.Tables[0].TableName = "WTGEW";
                }
                setReturn.Merge(setResult);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        }
        public DataSet GetRWASTPASS(DataRow dwWAFARBEN)
        {
            DataSet setReturn = new DataSet();
            DataSet setResult = new DataSet();
            try
            {
                orlReadCommand = OracleDB.CreateCommand();
                orlReadCommand.CommandText = "SELECT * FROM INTEX.WASTPASS WHERE WSPART = :ArticleNum AND WSPVAR=:ArticleVar";
                orlReadCommand.Parameters.Add("ArticleNum", OracleType.NVarChar).Value = dwWAFARBEN["WAFART"].ToString();
                orlReadCommand.Parameters.Add("ArticleVar", OracleType.NVarChar).Value = dwWAFARBEN["WAFVAR"].ToString();
                setResult = Connect2Proxy(orlReadCommand);
                if (setResult.Tables.Count > 0)
                {
                    setResult.Tables[0].TableName = "WASTPASS";
                }
                setReturn.Merge(setResult);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        }
        public DataSet NewWASTPASS(DataRow dwWASTAMM)
        {
            DataSet setReturn = new DataSet();
            setReturn.Merge(setINTEX.WASTPASS.Clone());
            DataRow dwWASTPASS = setReturn.Tables["WASTPASS"].NewRow();
            try
            {

                dwWASTPASS["WSPMANDANT"] = "00";

                foreach (DataColumn dc in setINTEX.WASTPASS.Columns)
                {
                    if (dc.DataType == System.Type.GetType("System.Decimal"))
                    {
                        dwWASTPASS[dc.ColumnName] = 0;
                    }
                }
                dwWASTPASS["WSPART"] = dwWASTAMM["WAART"];
                dwWASTPASS["WSPVAR"] = dwWASTAMM["WAVAR"];
                dwWASTPASS["WSPPOS"] = 1;
                string WSPPASS = dwWASTAMM["WAART"].ToString().Trim() + "." + dwWASTAMM["WAVAR"].ToString().Trim() + "                     ";
                dwWASTPASS["WSPPASS"] = Left(WSPPASS, 15);
                setReturn.Tables["WASTPASS"].Rows.Add(dwWASTPASS);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        }
        public DataSet NewWS22(DataRow dwWASTAMM)
        {
            DataSet setReturn = new DataSet();
            setReturn.Merge(setINTEX.WTGEW.Clone());
            DataRow dwWTGEW = setReturn.Tables["WTGEW"].NewRow();
            try
            {
                dwWTGEW["WTGMANDANT"] = "00";
                dwWTGEW["WTGART"] = dwWASTAMM["WAART"];
                dwWTGEW["WTGVAR"] = dwWASTAMM["WAVAR"];
                foreach (DataColumn dc in setINTEX.WTGEW.Columns)
                {
                    if (dc.DataType == System.Type.GetType("System.Decimal"))
                    {
                        dwWTGEW[dc.ColumnName] = 0;
                    }
                }

                dwWTGEW["WTGWBBRT"] = 1801;//筘幅>0
                dwWTGEW["WTGWBF"] = 1300;//筘齿密度>0
                dwWTGEW["WTGFDISM"] = 8000;//机上纬密>0
                dwWTGEW["WTGFDLGS"] = 1700;//底纬幅宽>0

                dwWTGEW["WTGSFLG"] = "1    ";//请输入纬向排花
                dwWTGEW["WTGSMTRS"] = 2000;

                dwWTGEW["WTGAENB"] = dwWASTAMM["WANEUB"];
                dwWTGEW["WTGAEND"] = dwWASTAMM["WANEUD"];
                dwWTGEW["WTGNEUB"] = dwWASTAMM["WANEUB"];
                dwWTGEW["WTGNEUD"] = dwWASTAMM["WANEUD"];
                setReturn.Tables["WTGEW"].Rows.Add(dwWTGEW);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        }
        public DataSet NewWAFARBEN(DataRow dwWASTAMM, string WAFZUART, string WAFZUSATZ)
        {
            DataSet setReturn = new DataSet();
            setReturn.Merge(setINTEX.WAFARBEN.Clone());
            DataRow dwWAFARBEN = setReturn.Tables["WAFARBEN"].NewRow();
            try
            {
                dwWAFARBEN["WAFMANDANT"] = "00";
                dwWAFARBEN["WAFART"] = dwWASTAMM["WAART"];
                dwWAFARBEN["WAFVAR"] = dwWASTAMM["WAVAR"];
                dwWAFARBEN["WAFZUART"] = WAFZUART;

                dwWAFARBEN["WAFZUSATZ"] = WAFZUSATZ;
                dwWAFARBEN["WAFBEZ"] = WAFZUSATZ;
                dwWAFARBEN["WAFAENDBEN"] = dwWASTAMM["WANEUB"];
                dwWAFARBEN["WAFAENDDAT"] = dwWASTAMM["WANEUD"];
                dwWAFARBEN["WAFNEUBEN"] = dwWASTAMM["WANEUB"];
                dwWAFARBEN["WAFNEUDAT"] = dwWASTAMM["WANEUD"];
                setReturn.Tables["WAFARBEN"].Rows.Add(dwWAFARBEN);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        }
        public DataSet GetWS31(DataRow dwWAFARBEN)
        {
            DataSet setReturn = new DataSet();
            DataSet setResult = new DataSet();
            try
            {
                ///
                orlReadCommand = OracleDB.CreateCommand();
                orlReadCommand.CommandText = "SELECT * FROM INTEX.WASTKE WHERE WAKART = :WAKART AND WAKVAR=:WAKVAR";
                orlReadCommand.Parameters.Add("WAKART", OracleType.NVarChar).Value = dwWAFARBEN["WAFART"].ToString();
                orlReadCommand.Parameters.Add("WAKVAR", OracleType.NVarChar).Value = dwWAFARBEN["WAFVAR"].ToString();
                //orlReadCommand.Parameters.Add("ArticleColor", OracleType.NVarChar).Value =dwWAFARBEN["WAFZUSATZ"].ToString().Trim();
                setResult = Connect2Proxy(orlReadCommand);
                if (setResult.Tables.Count > 0)
                {
                    setResult.Tables[0].TableName = "WASTKE";
                }
                setReturn.Merge(setResult);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        }
        public DataSet GetWS33(DataRow dwWAFARBEN)
        {
            DataSet setReturn = new DataSet();
            DataSet setResult = new DataSet();
            try
            {

                orlReadCommand = OracleDB.CreateCommand();
                orlReadCommand.CommandText = "SELECT  * FROM INTEX.WASTGA "
                + " WHERE WAGPSA='1' AND WAGPOS='00' AND WAGART = :WAGART AND WAGVAR=:WAGVAR AND WAGWCOL=:WAGWCOL";
                orlReadCommand.Parameters.Add("WAGART", OracleType.NVarChar).Value = dwWAFARBEN["WAFART"].ToString();
                orlReadCommand.Parameters.Add("WAGVAR", OracleType.NVarChar).Value = dwWAFARBEN["WAFVAR"].ToString();
                orlReadCommand.Parameters.Add("WAGWCOL", OracleType.NVarChar).Value = dwWAFARBEN["WAFZUSATZ"].ToString();
                setResult = Connect2Proxy(orlReadCommand);
                if (setResult.Tables.Count > 0)
                {
                    setResult.Tables[0].TableName = "WASTGA";
                }
                setReturn.Merge(setResult);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        }
        public DataSet InsertWASTKE(DataRow dwWAFARBEN, DataRow dwBSFARB)
        {
            DataSet set4Return = new DataSet();
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            OracleCommand or1;
            bool flgExist = false;
            try
            {
                #region============SELECT=========================
                or1 = OracleDB.CreateCommand();

                or1.CommandText = "SELECT * FROM WASTKE"
               + " WHERE WAKMANDANT=:WAKMANDANT AND WAKART=:WAKART AND WAKVAR=:WAKVAR AND WAKWCOL=:WAKWCOL";
                or1.Parameters.Add("WAKMANDANT", OracleType.NVarChar).Value = dwWAFARBEN["WAFMANDANT"].ToString();
                or1.Parameters.Add("WAKART", OracleType.NVarChar).Value = dwWAFARBEN["WAFART"].ToString();
                or1.Parameters.Add("WAKVAR", OracleType.NVarChar).Value = dwWAFARBEN["WAFVAR"].ToString();
                or1.Parameters.Add("WAKWCOL", OracleType.NVarChar).Value = dwWAFARBEN["WAFZUSATZ"].ToString();

                setResult = Connect2Proxy(or1);
                if (setResult.Tables.Count > 0)
                {
                    tbLocal = setResult.Tables[0];
                    tbLocal.TableName = "WASTKE";
                    if (tbLocal.Rows.Count > 0)
                    {
                        dwLocal = tbLocal.Rows[0];
                        flgExist = true;
                    }
                    else
                    {
                        dwLocal = tbLocal.NewRow();
                    }
                }
                #endregion
                #region============MAP============================
                if (dwLocal == null)
                {
                    dwLocal = setINTEX.WASTKE.NewRow();
                }
                dwLocal["WAKMANDANT"] = dwWAFARBEN["WAFMANDANT"].ToString();
                dwLocal["WAKART"] = dwWAFARBEN["WAFART"].ToString();
                dwLocal["WAKVAR"] = dwWAFARBEN["WAFVAR"].ToString();
                dwLocal["WAKWCOL"] = dwWAFARBEN["WAFZUSATZ"].ToString();
                dwLocal["WAKPOS"] = "01";
                dwLocal["WAKKART"] = dwBSFARB["BSFKART"].ToString();
                dwLocal["WAKKVAR"] = dwBSFARB["BSFKVAR"].ToString();
                dwLocal["WAKKFARBE"] = dwBSFARB["BSFKFARBE"].ToString();
                dwLocal["WAKEAFAKTR"] = 1200;

                #endregion
                #region============INSERT=========================
                if (!flgExist)
                {
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "INSERT INTO WASTKE(WAKMANDANT, WAKKUNDNR, WAKWERK, WAKABT, WAKART, WAKVAR, WAKWCOL, WAKPOS, WAKKART, WAKKVAR, WAKKFARBE, WAKBAUMKZ, WAKVERWEN, WAKANZBA, WAKDIVISOR, WAKEAFAKTM, WAKEAFAKTR, WAKDISPOKZ, WAKSTBR, WAKLLEIST, WAKRLEIST, WAKRBEM, WAKNET, WAKBRUT, WAKROSTA, WAKSBSTUE, WAKEARUE, WAKSTICH, WAKSCHIEART, WAKSCHIENE, WAKLAENG, WAKEINL, WAKSPANNV, WAKSPANNB, WAKSPANNF, WAKVERSATZ, WAKVARKZ, WAKFILLER, WAKAENZL, WAKAENB, WAKAEND, WAKNEUB, WAKNEUD)"
                        + "VALUES ("
                    + ":WAKMANDANT, '00000000', '   ', '   ',:WAKART, :WAKVAR, :WAKWCOL, :WAKPOS, '                    ', '  ', '          ', 'Z', 'P', '01', '01', 0, 0, 'B', 'D', '    ', '    ', '                 ', 10000, 10000, 'N', 'V', 0, 0, ' ', '     ', 0, 0, 0, 0, '00', 0, ' ', '                              ', 0, '        ', 0, '        ', 0)";
                    or1.Parameters.Add("WAKMANDANT", OracleType.NVarChar).Value = dwLocal["WAKMANDANT"].ToString();
                    or1.Parameters.Add("WAKART", OracleType.NVarChar).Value = dwLocal["WAKART"].ToString();
                    or1.Parameters.Add("WAKVAR", OracleType.NVarChar).Value = dwLocal["WAKVAR"].ToString();
                    or1.Parameters.Add("WAKWCOL", OracleType.NVarChar).Value = dwLocal["WAKWCOL"].ToString();
                    or1.Parameters.Add("WAKPOS", OracleType.NVarChar).Value = dwLocal["WAKPOS"].ToString();
                    setResult = Connect2Proxy(or1);
                }
                #endregion
                #region============UPDATE=========================

                or1 = OracleDB.CreateCommand();
                or1.CommandText = "UPDATE WASTKE SET WAKKART=:WAKKART,WAKKVAR=:WAKKVAR,WAKKFARBE=:WAKKFARBE,WAKEAFAKTR=:WAKEAFAKTR"
               + " WHERE WAKMANDANT=:WAKMANDANT AND WAKART=:WAKART AND WAKVAR=:WAKVAR  AND WAKWCOL=:WAKWCOL AND WAKPOS=:WAKPOS";
                or1.Parameters.Add("WAKMANDANT", OracleType.NVarChar).Value = dwLocal["WAKMANDANT"].ToString();
                or1.Parameters.Add("WAKART", OracleType.NVarChar).Value = dwLocal["WAKART"].ToString();
                or1.Parameters.Add("WAKVAR", OracleType.NVarChar).Value = dwLocal["WAKVAR"].ToString();
                or1.Parameters.Add("WAKWCOL", OracleType.NVarChar).Value = dwLocal["WAKWCOL"].ToString();
                or1.Parameters.Add("WAKPOS", OracleType.NVarChar).Value = dwLocal["WAKPOS"].ToString();
                or1.Parameters.Add("WAKKART", OracleType.NVarChar).Value = dwLocal["WAKKART"].ToString();
                or1.Parameters.Add("WAKKVAR", OracleType.NVarChar).Value = dwLocal["WAKKVAR"].ToString();
                or1.Parameters.Add("WAKKFARBE", OracleType.NVarChar).Value = dwLocal["WAKKFARBE"].ToString();
                or1.Parameters.Add("WAKEAFAKTR", OracleType.NVarChar).Value = dwLocal["WAKEAFAKTR"].ToString();

                setResult = Connect2Proxy(or1);
                #endregion
                #region============SELECT=========================
                or1 = OracleDB.CreateCommand();

                or1.CommandText = "SELECT * FROM WASTKE"
               + " WHERE WAKMANDANT=:WAKMANDANT AND WAKART=:WAKART AND WAKVAR=:WAKVAR AND WAKWCOL=:WAKWCOL";
                or1.Parameters.Add("WAKMANDANT", OracleType.NVarChar).Value = dwLocal["WAKMANDANT"].ToString();
                or1.Parameters.Add("WAKART", OracleType.NVarChar).Value = dwLocal["WAKART"].ToString();
                or1.Parameters.Add("WAKVAR", OracleType.NVarChar).Value = dwLocal["WAKVAR"].ToString();
                or1.Parameters.Add("WAKWCOL", OracleType.NVarChar).Value = dwLocal["WAKWCOL"].ToString();

                setResult = Connect2Proxy(or1);
                if (setResult.Tables.Count > 0)
                {
                    tbLocal = setResult.Tables[0];
                    tbLocal.TableName = "WASTKE";
                }
                set4Return.Merge(setResult);
                #endregion
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return set4Return;

        }
        public DataSet InsertWASTGA(DataRow dwWASTGA)
        {
            DataSet set4Return = new DataSet();
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            OracleCommand or1 = OracleDB.CreateCommand();
            try
            {

                #region==========SELECT========================
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT * FROM WASTGA WHERE  "
                + "  WAGMANDANT=:WAGMANDANT AND WAGART=:WAGART AND WAGVAR=:WAGVAR AND WAGWCOL=:WAGWCOL AND WAGPOS=:WAGPOS AND WAGFOLGEPOS=:WAGFOLGEPOS";
                or1.Parameters.Add("WAGMANDANT", OracleType.NVarChar).Value = dwWASTGA["WAGMANDANT"].ToString();
                or1.Parameters.Add("WAGART", OracleType.NVarChar).Value = dwWASTGA["WAGART"].ToString();
                or1.Parameters.Add("WAGVAR", OracleType.NVarChar).Value = dwWASTGA["WAGVAR"].ToString();
                or1.Parameters.Add("WAGWCOL", OracleType.NVarChar).Value = dwWASTGA["WAGWCOL"].ToString(); ;
                or1.Parameters.Add("WAGPOS", OracleType.NVarChar).Value = dwWASTGA["WAGPOS"].ToString(); ;
                or1.Parameters.Add("WAGFOLGEPOS", OracleType.Number).Value = dwWASTGA["WAGFOLGEPOS"].ToString();

                setResult = Connect2Proxy(or1);
                if (setResult.Tables.Count > 0)
                {
                    tbLocal = setResult.Tables[0];
                    tbLocal.TableName = "WASTGA";
                    if (tbLocal.Rows.Count > 0)
                    {
                        dwLocal = tbLocal.Rows[0];
                        flgExist = true;
                    }
                    else
                    {
                        dwLocal = tbLocal.NewRow();
                    }
                }
                #endregion

                #region==========MAP=============================
                dwLocal["WAGMANDANT"] = dwWASTGA["WAGMANDANT"];
                dwLocal["WAGART"] = dwWASTGA["WAGART"];
                dwLocal["WAGVAR"] = dwWASTGA["WAGVAR"];
                dwLocal["WAGWCOL"] = dwWASTGA["WAGWCOL"];
                dwLocal["WAGPOS"] = dwWASTGA["WAGPOS"];
                dwLocal["WAGFOLGEPOS"] = dwWASTGA["WAGFOLGEPOS"];
                dwLocal["WAGGART"] = dwWASTGA["WAGGART"];
                dwLocal["WAGGVAR"] = dwWASTGA["WAGGVAR"];
                dwLocal["WAGGFARBE"] = dwWASTGA["WAGGFARBE"];
                dwLocal["WAGFDZ"] = dwWASTGA["WAGFDZ"];
                dwLocal["WAGABF"] = dwWASTGA["WAGABF"];
                dwLocal["WAGKGNET"] = dwWASTGA["WAGKGNET"];
                dwLocal["WAGKGBRUT"] = dwWASTGA["WAGKGBRUT"];
                dwLocal["WAGDISPOKZ"] = dwWASTGA["WAGDISPOKZ"];
                dwLocal["WAGBEM"] = dwWASTGA["WAGBEM"];
                dwLocal["WAGVARKZ"] = dwWASTGA["WAGVARKZ"];
                #endregion

                #region==========INSERT========================
                if (!flgExist)
                {
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "INSERT INTO WASTGA(WAGMANDANT, WAGKUNDNR, WAGWERK, WAGABT, WAGART, WAGVAR, WAGWCOL, WAGPSA, WAGPOS, WAGFOLGEPOS, WAGGART, WAGGVAR, WAGGFARBE, WAGFDZ, WAGABF, WAGKGNET, WAGKGBRUT, WAGDISPOKZ, WAGBEM, WAGEAFAKTOR, WAGGRLFDM, WAGKZQM, WAGPROZWG, WAGABFALL, WAGAUFM, WAGANT, WAGEINL, WAGSPANNV, WAGSPANNB, WAGSPANNF, WAGVARKZ, WAGNA1, WAGNA2, WAGNA3, WAGNA4, WAGNA5, WAGNP, WAGWEAVIN, WAGWEEMBR, WAGFLOATING, WAGFL, WAGFLNA1, WAGFLNA2, WAGFLNA3, WAGFLNA4, WAGFLNA5, WAGFLNP, WAGFILLER)"
                        + "VALUES (:WAGMANDANT, '00000000', '   ', '   ',:WAGART, :WAGVAR, :WAGWCOL, '1', :WAGPOS, :WAGFOLGEPOS, '                    ', '   ', '          '"
                    + ", 12, 0, 0, 30, 'B', '          ', 0, 0, ' ', 0, 0, '  ', 0, 0, 0, 0, '00', ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, '  ', 0, 0, 0, 0, 0, 0, '                                                                           ')";
                    setResult = Connect2Proxy(or1);
                    or1.Parameters.Add("WAGMANDANT", OracleType.NVarChar).Value = dwLocal["WAGMANDANT"].ToString();
                    or1.Parameters.Add("WAGART", OracleType.NVarChar).Value = dwLocal["WAGART"].ToString();
                    or1.Parameters.Add("WAGVAR", OracleType.NVarChar).Value = dwLocal["WAGVAR"].ToString();
                    or1.Parameters.Add("WAGWCOL", OracleType.NVarChar).Value = dwLocal["WAGWCOL"].ToString(); ;
                    or1.Parameters.Add("WAGPOS", OracleType.NVarChar).Value = dwLocal["WAGPOS"].ToString();
                    or1.Parameters.Add("WAGFOLGEPOS", OracleType.Number).Value = dwLocal["WAGFOLGEPOS"].ToString();

                    setResult = Connect2Proxy(or1);
                }
                #endregion

                #region==========UPDATE========================
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "UPDATE WASTGA SET WAGGART=:WAGGART, WAGGVAR=:WAGGVAR,WAGGFARBE=:WAGGFARBE"
                    + ",WAGFDZ=:WAGFDZ,WAGABF=:WAGABF,WAGKGNET=:WAGKGNET,WAGKGBRUT=:WAGKGBRUT"
                    + " WHERE "
                    + "  WAGMANDANT=:WAGMANDANT AND WAGART=:WAGART AND WAGVAR=:WAGVAR AND WAGWCOL=:WAGWCOL AND WAGPOS=:WAGPOS AND WAGFOLGEPOS=:WAGFOLGEPOS";
                or1.Parameters.Add("WAGMANDANT", OracleType.NVarChar).Value = dwLocal["WAGMANDANT"].ToString();
                or1.Parameters.Add("WAGART", OracleType.NVarChar).Value = dwLocal["WAGART"].ToString();
                or1.Parameters.Add("WAGVAR", OracleType.NVarChar).Value = dwLocal["WAGVAR"].ToString();
                or1.Parameters.Add("WAGWCOL", OracleType.NVarChar).Value = dwLocal["WAGWCOL"].ToString(); ;
                or1.Parameters.Add("WAGPOS", OracleType.NVarChar).Value = dwLocal["WAGPOS"].ToString();
                or1.Parameters.Add("WAGFOLGEPOS", OracleType.Number).Value = dwLocal["WAGFOLGEPOS"].ToString();
                or1.Parameters.Add("WAGGART", OracleType.NVarChar).Value = dwLocal["WAGGART"].ToString();
                or1.Parameters.Add("WAGGVAR", OracleType.NVarChar).Value = dwLocal["WAGGVAR"].ToString();
                or1.Parameters.Add("WAGGFARBE", OracleType.NVarChar).Value = dwLocal["WAGGFARBE"].ToString();
                or1.Parameters.Add("WAGFDZ", OracleType.Number).Value = dwLocal["WAGFDZ"].ToString();
                or1.Parameters.Add("WAGABF", OracleType.Number).Value = dwLocal["WAGABF"].ToString();
                or1.Parameters.Add("WAGKGNET", OracleType.Number).Value = dwLocal["WAGKGNET"].ToString();
                or1.Parameters.Add("WAGKGBRUT", OracleType.Number).Value = dwLocal["WAGKGBRUT"].ToString();
                setResult = Connect2Proxy(or1);
                #endregion
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return set4Return;
        }
        public DataSet InsertWASTAMM(DataRow dwInput, DataRow dwDispo)
        {
            DataSet set4Return = new DataSet();
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            OracleCommand or1;
            try
            {
                #region==========SELECT========================
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT * FROM WASTAMM WHERE  "
                + "  WAMANDANT=:WAMANDANT AND WAART=:WAART AND WAVAR=:WAVAR";
                or1.Parameters.Add("WAMANDANT", OracleType.NVarChar).Value = dwInput["WAMANDANT"].ToString();
                or1.Parameters.Add("WAART", OracleType.NVarChar).Value = dwInput["WAART"].ToString();
                or1.Parameters.Add("WAVAR", OracleType.NVarChar).Value = dwInput["WAVAR"].ToString();

                setResult = Connect2Proxy(or1);
                if (setResult.Tables.Count > 0)
                {
                    tbLocal = setResult.Tables[0];
                    tbLocal.TableName = "WASTAMM";
                    if (tbLocal.Rows.Count > 0)
                    {
                        flgExist = true;
                        dwLocal = tbLocal.Rows[0];
                    }
                    else
                    {
                        dwLocal = tbLocal.NewRow();
                    }
                }
                #endregion

                #region==========MAP===========================
                dwLocal["WAMANDANT"] = Left(dwInput["WAMANDANT"].ToString() + "  ", 2);
                dwLocal["WAART"] = Left(dwInput["WAART"].ToString() + "                                         ", 20);
                dwLocal["WAVAR"] = Left(dwInput["WAVAR"].ToString() + "  ", 2);
                dwLocal["WAVWART"] = Left(dwInput["WAART"].ToString() + "                                         ", 20);
                dwLocal["WAVWVAR"] = Left(dwInput["WAVAR"].ToString() + "  ", 2);
                dwLocal["WAKAART"] = Left(dwInput["WAART"].ToString() + "                                         ", 20);
                dwLocal["WAKAVAR"] = Left(dwInput["WAVAR"].ToString() + "  ", 2);

                dwLocal["WADART"] = Left(dwInput["WADART"].ToString() + "                                         ", 20);
                dwLocal["WADVAR"] = Left(dwInput["WADVAR"].ToString() + "  ", 2);
                dwLocal["WASUBSTGR"] = Left(dwInput["WAART"].ToString() + "                                         ", 3);

                dwLocal["WABEZ"] = Left(dwInput["WABEZ"].ToString().Trim() + "                                         ", 40);
                dwLocal["WARBEM"] = Left(dwInput["WARBEM"].ToString().Trim() + "                                         ", 40);
                dwLocal["WAAENB"] = dwInput["WAAENB"];
                dwLocal["WAAEND"] = dwInput["WAAEND"];
                dwLocal["WANEUB"] = dwInput["WANEUB"].ToString();
                dwLocal["WANEUD"] = dwInput["WANEUD"].ToString();

                dwLocal["WARSTDLG"] = dwInput["WARSTDLG"];
                dwLocal["WAGFKZ"] = dwInput["WAGFKZ"];
                dwLocal["WAFSTDLG"] = dwInput["WARSTDLG"];
                dwLocal["WAFFERTKZ"] = dwInput["WAFFERTKZ"];
                dwLocal["WAFRBST"] = dwInput["WAFRBST"];

                if (dwLocal["WARFERTKZ"].ToString() != "E")
                {
                    dwLocal["WARFERTKZ"] = dwInput["WARFERTKZ"];

                    dwLocal["WAGASTA"] = dwInput["WAGASTA"];
                    dwLocal["WAMASTA"] = dwInput["WAMASTA"];
                    dwLocal["WAKESTA"] = dwInput["WAKESTA"];
                    dwLocal["WAMATPRF"] = dwInput["WAMATPRF"];
                    dwLocal["WABRTPRF"] = dwInput["WABRTPRF"];
                    dwLocal["WASTKGP"] = dwInput["WASTKGP"];
                    dwLocal["WASCHLIP"] = dwInput["WASCHLIP"];
                    dwLocal["WASCHLIA"] = dwInput["WASCHLIA"];
                    dwLocal["WALIEFNR"] = dwInput["WALIEFNR"];
                    dwLocal["WAEG"] = dwInput["WAEG"];
                }

                //user interface validate something
                dwLocal["WARWBRT"] = dwInput["WARWBRT"];
                dwLocal["WAFBRTL"] = dwInput["WAFBRTL"];


                dwLocal["WARFDDIK"] = dwInput["WARFDDIK"];
                dwLocal["WARFDDIS"] = dwInput["WARFDDIS"];
                dwLocal["WAFFDDIK"] = dwInput["WAFFDDIK"];
                dwLocal["WAFFDDIS"] = dwInput["WAFFDDIS"];

                dwLocal["WABIND"] = Left(dwInput["WABIND"].ToString() + "               ", 15);
                dwLocal["WAEINZNR"] = Left(dwInput["WAEINZNR"].ToString() + "                ", 15);
                dwLocal["WALAEAEND"] = dwInput["WALAEAEND"];

                dwLocal["WAFDDIM"] = dwInput["WAFDDIM"];
                dwLocal["WARGRLFD"] = dwInput["WARGRLFD"];
                dwLocal["WAFGRLFD"] = dwInput["WAFGRLFD"];
                dwLocal["WARGWTOL"] = dwInput["WARGWTOL"];
                dwLocal["WATSDSCH"] = dwInput["WATSDSCH"];
                dwLocal["WAFGRQM"] = dwInput["WAFGRQM"];
                dwLocal["WARGRQM"] = dwInput["WARGRQM"];
                dwLocal["WAFSTDGW"] = dwInput["WAFSTDGW"];
                dwLocal["WARSTDGW"] = dwInput["WARSTDGW"];
                dwLocal["WAARTGRP"] = dwInput["WAARTGRP"];
                dwLocal["WAPROGRP"] = dwInput["WAPROGRP"];
                dwLocal["WARSTDLG"] = dwInput["WARSTDLG"];
                dwLocal["WAFSTDLG"] = dwInput["WAFSTDLG"];
                #endregion

                #region==========INSERT========================
                if (!flgExist)
                {
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "INSERT INTO WASTAMM(WAMANDANT, WAKUNDNR, WAWERK, WAABT, WAART, WAVAR, WAAENZL, WAAENB, WAAEND, WANEUB, WANEUD, WABEZ, WAMTART, WAMU, WARKZ, WAFKZ, WAMUART, WAMUNR, WAHERLD, WAFDDIM, WAMURLOD, WAMUPROD, WAMUCTOD, WAMUDTRL, WAMUBIRL, WAGASTA, WAMASTA, WAKESTA, WAROSTA, WARBSTA, WAFBSTA, WARPROF, WAFPROF, WARLSTA, WAFLSTA, WARSTAKZ, WAWAART, WARFERTKZ, WARKL, WARMEHRB, WARVOLL, WARAUFM, WATRAUFM, WATRLG, WARSTDLG, WARSTDGW, WARABLOM, WARMUNR, WARBEM, WATEXTE1, WATEXTE2, WATEXTE3, WATEXTE4, WAKRITI, WARGKZ1, WAGFKZ, WARAUFT, WARAUFD, WARUNGLFM, WARUNGQM, WARUNBRT, WARUNFDK, WARUNFDS, WARWBRT, WARBRLST, WARBRTOL, WARGRQM, WARGRLFD, WARGWTOL, WARARTDICKE, WARARTTOLP, WARARTTOLM, WARFDDIK, WARFDDIS, WABIND, WARIPP, WASCHLICHTGR, WASCHLICHTNR, WAEINZNR, WATSDSCH, WASTTEIL, WAFSTAKZ, WAFFERTKZ, WAAUSART, WASTUEART, WAVWART, WAVWVAR, WAVARFR, WAFMEHRB, WAFVOLL, WAFAUFM, WAFSTDLG, WAFSTDGW, WAFABLOM, WAGVORL, WAOVORL, WAFRBST, WALAMFR, WAFGKZ1, WAFGKZ2, WAFGKZ3, WASCHLKZ, WAFAUFT, WAFAUFD, WAFKART, WAKOLL, WAFBEM, WAFUNGLFM, WAFUNGQM, WAFUNBRT, WAFUNFDK, WAFUNFDS, WAFBRTU, WAFBRTUT, WAFBRTL, WAFBRTLT, WASCHNK, WALAEAEND, WARENDEM, WARENDEMNT, WAGWVERL, WAALKV, WAFGRQM, WAFGRLFD, WAFGWTOL, WAFARTDICKE, WAFARTTOLP, WAFARTTOLM, WAFFDDIK, WAFFDDIS, WAUNI, WACOLORKZ, WAUNIGA, WAGEWICHT2, WAFVERF1, WAFVERF2, WAFVERF3, WAFVERF4, WAFZUSTAND1, WAFZUSTAND2, WAFZUSTAND3, WAFZUSTAND4, WAFVERFN1, WAFVERFN2, WAFVERFN3, WAFVERFN4, WAFFGRPN1, WAFFGRPN2, WAFFGRPN3, WAFFGRPN4, WAVNRKZ, WAZUSTKZ, WAUEKLOKZ, WAFSUBST, WAMAXFA, WAAKZWG, WAFRESTF, WADRUCKBAR, WAVBRGQM, WALEDR, WADVERF1, WADVERF2, WADVERF3, WADVERF4, WADZUSTAND1, WADZUSTAND2, WADZUSTAND3, WADZUSTAND4, WADVERFN1, WADVERFN2, WADVERFN3, WADVERFN4, WADFGRPN1, WADFGRPN2, WADFGRPN3, WADFGRPN4, WADSUBST, WADRESTF, WAFAKTOR, WABSUBST, WAVORBWA, WANACHBWA, WAVORBFB, WANACHBFB, WAVORBDR, WANACHBDR, WAVORBAP, WANACHBAP, WAMVB, WAMNB, WACVB, WACNB, WABVB, WABNB, WASVB, WASNB, WASUBSTGR, WAHANDICAP, WAZUSCHAB, WALOSGRFB, WAQCCHECK, WADART, WADVAR, WADSTDKZ, WADSACHB, WASCHNKZ, WAPROGRP, WAARTGRP, WAWBZEIT, WAMINBST, WAMAXBST, WAOPTMGR, WAOPTMGF, WARMINPMENG, WAFMINPMENG, WAUEBM, WAUEBG, WAUEBF, WAMATPRF, WABRTPRF, WAGQMPRF, WASTKGP, WASCHLIP, WASCHLIA, WALPABR, WADISPZS, WADRPAR, WAZUSTR, WAWDSUM, WASTSKZ, WASTSART, WASTSAUF, WASTSLG, WASTSBRT, WASTSDKZ, WAFILLER1, WAVOLU, WAANAB, WAALBIS, WAPLGRP, WAPRODH, WAMATKL, WAPMGRP, WAPRFSCHL, WAKAART, WAKAVAR, WAKASTD, WAKAZGRP, WAKAPRGRPN1, WAKAPRGRPN2, WAKAPRGRPN3, WAKAAGRA, WAKAAGRP, WAZWTWAHL, WAVERL, WAABR, WAABRTOL, WAKABRT, WARKABRTOL, WAFKABRTOL, WAMATKTO, WAKTO1, WAGV, WAKBON, WAMGKMM, WAMEZ, WAWAG, WABKLAS, WABWPLAN, WAEKGRP, WABSTME, WAVABME, WAEKWSL, WALIEFNR, WAEG, WABON, WAKUNDE, WALOHNW, WALOHNA, WASCHLIAUF, WAPFCODE, WAAUFKZ, WAMRKM1, WAMRKM2, WAMRKM3, WAMRKM4, WAMRKM5, WAESACHB, WAESACHBKZ, WAFBGRLFM, WAPRUEFKZ, WAPRUEFBEN, WAPRUEFDAT, WARAVGRP, WATAX, WAPARTBA, WAFDDIF, WAFILLER2)"
                        + "VALUES (:WAMANDANT, '00000000', '   ', '   ', :WAART, :WAVAR, 1, '        ', 0, :WANEUB, :WANEUD, '                                        ', '    ', ' ', 'J', 'J', '                    ', '                    ', '   ', 'INC', '00', '00', ' ', 0, '        ', 'V', 'V', 'V', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'A', 'GEW', 'E', '    ', ' ', 'P', '  ', '  ', 0, 200000, 25400, '          ', '               ', '                                        ', '          ', '          ', '          ', '          ', 'N', ' ', 'J', '        ', 0, ' ', ' ', ' ', ' ', ' ', 0, 0, 0, 0, 0, 0, '0000', '0000', '0000', 0, 0, '               ', 0, '     ', '000000000000000', '               ', 0, 'J', 'A', 'E', 'FI  ', '   ', '                    ', '  ', 'J', ' ', 'P', '  ', 0, 0, '          ', '          ', '          ', 'C ', 'N', ' ', ' ', ' ', ' ', '        ', 0, '          ', '     ', '                                        ', ' ', ' ', ' ', ' ', ' ', 0, 0, 0, 0, 0,0, 0, 0, 0, '00', 0, 0, 0, '0000', '0000', '0000', 0, 0, ' ', ' ', ' ', 0, '   ', '   ', '   ', '   ', '    ', '    ', '    ', '    ', '   ', '   ', '   ', '   ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '               ', 0, 0, 0, ' ', 0, 0, '   ', '   ', '   ', '   ', '    ', '    ', '    ', '    ', '   ', '   ', '   ', '   ', ' ', ' ', ' ', ' ', '               ', 0, 0, '               ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', '   ', 0, 0, ' ', '                    ', '  ', 'J', '        ', ' ', '   ', '   ', '00', 0, 0, 5000, 5000, 0, 0, 'MTR', '2', '000001000000', ' ', ' ', ' ', ' ', ' ', ' ', 'N', 'N', '     ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '         ', 0, 0, 0, '  ', '                  ', '         ', '    ', '         ', '                    ', '  ', 'J', 'GGG', ' ', ' ', ' ', '     ', '  ', 80, 50, 0, '0', 0, 0, 0, '      ', '      ', '      ', 0, '        ', 0, 0, '    ', ' ', '   ', '   ', ' ', '    ', '        ', 'N', 'N', '        ', '                    ', '                    ', 0, '     ', ' ', '    ', '    ', '    ', '    ', '    ', '        ', 'B', 0, 'N', '        ', 0, '10  ', 'RMB', ' ', 25400, '                                                      ')";
                    or1.Parameters.Add("WAMANDANT", OracleType.NVarChar).Value = dwLocal["WAMANDANT"].ToString();
                    or1.Parameters.Add("WAART", OracleType.NVarChar).Value = dwLocal["WAART"].ToString();
                    or1.Parameters.Add("WAVAR", OracleType.NVarChar).Value = dwLocal["WAVAR"].ToString();
                    or1.Parameters.Add("WANEUB", OracleType.NVarChar).Value = dwLocal["WANEUB"].ToString();
                    or1.Parameters.Add("WANEUD", OracleType.Number).Value = dwLocal["WANEUD"].ToString();

                    Connect2Proxy(or1);

                }
                #endregion

                #region==========UPDATE========================
                setResult = InsertAPZUORD(dwLocal["WAMANDANT"].ToString(), dwLocal["WAART"].ToString(), dwLocal["WAVAR"].ToString(), "F", dwDispo["FAPKRS"].ToString(), dwDispo["FAPNR"].ToString());
                setResult = InsertAPZUORD(dwLocal["WAMANDANT"].ToString(), dwLocal["WAART"].ToString(), dwLocal["WAVAR"].ToString(), "R", dwDispo["RAPKRS"].ToString(), dwDispo["RAPNR"].ToString());
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "UPDATE WASTAMM SET WABEZ=:WABEZ,WARBEM=:WARBEM"
                    + ",WAAENB=:WAAENB,WAAEND=:WAAEND"
                     + ",WAVWART=:WAVWART,WAVWVAR=:WAVWVAR,WAKAART=:WAKAART,WAKAVAR=:WAKAVAR,WADART=:WADART,WADVAR=:WADVAR"
                     + ",WASUBSTGR=:WASUBSTGR,WAPROGRP=:WAPROGRP,WAARTGRP=:WAARTGRP,WAFDDIM=:WAFDDIM"
                     + ",WAFFERTKZ=:WAFFERTKZ,WARFERTKZ=:WARFERTKZ,WAGFKZ=:WAGFKZ,WAFRBST=:WAFRBST"
                     + ",WAGASTA=:WAGASTA,WAMASTA=:WAMASTA,WAKESTA=:WAKESTA,WAMATPRF=:WAMATPRF,WABRTPRF=:WABRTPRF,WASTKGP=:WASTKGP,WASCHLIP=:WASCHLIP,WASCHLIA=:WASCHLIA,WALIEFNR=:WALIEFNR,WAEG=:WAEG"
                     + ",WARSTDLG=:WARSTDLG,WARSTDGW=:WARSTDGW,WAFSTDLG=:WAFSTDLG,WAFSTDGW=:WAFSTDGW "
                     + ",WARWBRT= :WARWBRT,WAFBRTL=:WAFBRTL,WARGRQM=:WARGRQM, WAFGRQM=:WAFGRQM, WARGRLFD=:WARGRLFD, WAFGRLFD=:WAFGRLFD, WARGWTOL=:WARGWTOL"
                     + ",WARFDDIK=:WARFDDIK, WARFDDIS=:WARFDDIS, WAFFDDIK=:WAFFDDIK,WAFFDDIS=:WAFFDDIS,WABIND=:WABIND, WAEINZNR=:WAEINZNR, WATSDSCH=:WATSDSCH, WALAEAEND=:WALAEAEND"
                    + " WHERE  "
             + "  WAMANDANT=:WAMANDANT AND WAART=:WAART AND WAVAR=:WAVAR";

                or1.Parameters.Add("WAMANDANT", OracleType.NVarChar).Value = dwLocal["WAMANDANT"].ToString();
                or1.Parameters.Add("WAART", OracleType.NVarChar).Value = dwLocal["WAART"].ToString();
                or1.Parameters.Add("WAVAR", OracleType.NVarChar).Value = dwLocal["WAVAR"].ToString();
                or1.Parameters.Add("WABEZ", OracleType.NVarChar).Value = dwLocal["WABEZ"].ToString();
                or1.Parameters.Add("WARBEM", OracleType.NVarChar).Value = dwLocal["WARBEM"].ToString();
                or1.Parameters.Add("WAAENB", OracleType.NVarChar).Value = dwLocal["WAAENB"].ToString();
                or1.Parameters.Add("WAAEND", OracleType.DateTime).Value = dwLocal["WAAEND"].ToString();

                or1.Parameters.Add("WAVWART", OracleType.NVarChar).Value = dwLocal["WAVWART"].ToString();
                or1.Parameters.Add("WAVWVAR", OracleType.NVarChar).Value = dwLocal["WAVWVAR"].ToString();
                or1.Parameters.Add("WAKAART", OracleType.NVarChar).Value = dwLocal["WAKAART"].ToString();
                or1.Parameters.Add("WAKAVAR", OracleType.NVarChar).Value = dwLocal["WAKAVAR"].ToString();
                or1.Parameters.Add("WADART", OracleType.NVarChar).Value = dwLocal["WADART"].ToString();
                or1.Parameters.Add("WADVAR", OracleType.NVarChar).Value = dwLocal["WADVAR"].ToString();

                or1.Parameters.Add("WASUBSTGR", OracleType.NVarChar).Value = dwLocal["WASUBSTGR"].ToString();
                or1.Parameters.Add("WAPROGRP", OracleType.NVarChar).Value = dwLocal["WAPROGRP"].ToString();
                or1.Parameters.Add("WAARTGRP", OracleType.NVarChar).Value = dwLocal["WAARTGRP"].ToString();
                or1.Parameters.Add("WAFFERTKZ", OracleType.NVarChar).Value = dwLocal["WAFFERTKZ"].ToString();
                or1.Parameters.Add("WARFERTKZ", OracleType.NVarChar).Value = dwLocal["WARFERTKZ"].ToString();
                or1.Parameters.Add("WAGFKZ", OracleType.NVarChar).Value = dwLocal["WAGFKZ"].ToString();
                or1.Parameters.Add("WAFRBST", OracleType.NVarChar).Value = dwLocal["WAFRBST"].ToString();

                or1.Parameters.Add("WAGASTA", OracleType.NVarChar).Value = dwLocal["WAGASTA"].ToString();
                or1.Parameters.Add("WAMASTA", OracleType.NVarChar).Value = dwLocal["WAMASTA"].ToString();
                or1.Parameters.Add("WAKESTA", OracleType.NVarChar).Value = dwLocal["WAKESTA"].ToString();
                or1.Parameters.Add("WAMATPRF", OracleType.NVarChar).Value = dwLocal["WAMATPRF"].ToString();
                or1.Parameters.Add("WABRTPRF", OracleType.NVarChar).Value = dwLocal["WABRTPRF"].ToString();
                or1.Parameters.Add("WASTKGP", OracleType.NVarChar).Value = dwLocal["WASTKGP"].ToString();
                or1.Parameters.Add("WASCHLIP", OracleType.NVarChar).Value = dwLocal["WASCHLIP"].ToString();
                or1.Parameters.Add("WASCHLIA", OracleType.NVarChar).Value = dwLocal["WASCHLIA"].ToString();
                or1.Parameters.Add("WALIEFNR", OracleType.NVarChar).Value = dwLocal["WALIEFNR"].ToString();
                or1.Parameters.Add("WAEG", OracleType.NVarChar).Value = dwLocal["WAEG"].ToString();

                or1.Parameters.Add("WAFDDIM", OracleType.NVarChar).Value = dwLocal["WAFDDIM"].ToString();

                or1.Parameters.Add("WARSTDLG", OracleType.Number).Value = dwLocal["WARSTDLG"].ToString();
                or1.Parameters.Add("WARSTDGW", OracleType.Number).Value = dwLocal["WARSTDGW"].ToString();
                or1.Parameters.Add("WAFSTDLG", OracleType.Number).Value = dwLocal["WAFSTDLG"].ToString();
                or1.Parameters.Add("WAFSTDGW", OracleType.Number).Value = dwLocal["WAFSTDGW"].ToString();

                or1.Parameters.Add("WARWBRT", OracleType.Number).Value = dwLocal["WARWBRT"].ToString();
                or1.Parameters.Add("WAFBRTL", OracleType.Number).Value = dwLocal["WAFBRTL"].ToString();
                or1.Parameters.Add("WARGRQM", OracleType.Number).Value = dwLocal["WARGRQM"].ToString();
                or1.Parameters.Add("WAFGRQM", OracleType.Number).Value = dwLocal["WAFGRQM"].ToString();
                or1.Parameters.Add("WARGRLFD", OracleType.Number).Value = dwLocal["WARGRLFD"].ToString();
                or1.Parameters.Add("WAFGRLFD", OracleType.Number).Value = dwLocal["WAFGRLFD"].ToString();
                or1.Parameters.Add("WARGWTOL", OracleType.Number).Value = dwLocal["WARGWTOL"].ToString();

                or1.Parameters.Add("WARFDDIK", OracleType.Number).Value = dwLocal["WARFDDIK"].ToString();
                or1.Parameters.Add("WARFDDIS", OracleType.Number).Value = dwLocal["WARFDDIS"].ToString();
                or1.Parameters.Add("WAFFDDIK", OracleType.Number).Value = dwLocal["WAFFDDIK"].ToString();
                or1.Parameters.Add("WAFFDDIS", OracleType.Number).Value = dwLocal["WAFFDDIS"].ToString();
                or1.Parameters.Add("WABIND", OracleType.NVarChar).Value = dwLocal["WABIND"].ToString();
                or1.Parameters.Add("WAEINZNR", OracleType.NVarChar).Value = dwLocal["WAEINZNR"].ToString();
                or1.Parameters.Add("WATSDSCH", OracleType.NVarChar).Value = dwLocal["WATSDSCH"].ToString();
                or1.Parameters.Add("WALAEAEND", OracleType.NVarChar).Value = dwLocal["WALAEAEND"].ToString();

                setResult = Connect2Proxy(or1);
                #endregion

                #region==========SELECT========================
                /*
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT * FROM WASTAMM WHERE  "
              + "  WAMANDANT=:WAMANDANT AND WAART=:WAART AND WAVAR=:WAVAR";
                or1.Parameters.Add("WAMANDANT", OracleType.NVarChar).Value = dwInput["WAMANDANT"].ToString();
                or1.Parameters.Add("WAART", OracleType.NVarChar).Value = dwInput["WAART"].ToString();
                or1.Parameters.Add("WAVAR", OracleType.NVarChar).Value = dwInput["WAVAR"].ToString();
                setResult = Connect2Proxy(or1);
                if (setResult.Tables.Count > 0)
                {
                    tbLocal = setResult.Tables[0];
                    tbLocal.TableName = "WASTAMM";
                }*/
                #endregion
                set4Return.Merge(setResult);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return set4Return;
        }
        public DataSet InsertWTGEW(DataRow dwInput)
        {
            DataSet set4Return = new DataSet();
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            OracleCommand or1 = OracleDB.CreateCommand();
            bool flgExist = false;
            try
            {
                #region==========SELECT========================
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT *FROM WTGEW WHERE   "
                + "  WTGMANDANT=:WTGMANDANT AND WTGART=:WTGART AND WTGVAR=:WTGVAR";
                or1.Parameters.Add("WTGMANDANT", OracleType.NVarChar).Value = dwInput["WTGMANDANT"].ToString();
                or1.Parameters.Add("WTGART", OracleType.NVarChar).Value = dwInput["WTGART"].ToString();
                or1.Parameters.Add("WTGVAR", OracleType.NVarChar).Value = dwInput["WTGVAR"].ToString();

                setResult = Connect2Proxy(or1);
                if (setResult.Tables.Count > 0)
                {
                    tbLocal = setResult.Tables[0];
                    tbLocal.TableName = "WTGEW";
                    if (tbLocal.Rows.Count > 0)
                    {
                        flgExist = true;
                        dwLocal = tbLocal.Rows[0];
                    }
                    else
                    {
                        dwLocal = tbLocal.NewRow();
                    }
                }
                #endregion
                #region==========MPP===========================
                dwLocal["WTGMANDANT"] = Left(dwInput["WTGMANDANT"].ToString() + "            ", 2);
                dwLocal["WTGART"] = Left(dwInput["WTGART"].ToString() + "                                         ", 20);
                dwLocal["WTGVAR"] = Left(dwInput["WTGVAR"].ToString() + "           ", 2);
                dwLocal["WTGSFLG"] = Left(dwInput["WTGSFLG"].ToString() + "                                         ", 15);
                dwLocal["WTGAENB"] = dwInput["WTGAENB"];
                dwLocal["WTGAEND"] = dwInput["WTGAEND"];
                dwLocal["WTGNEUB"] = dwInput["WTGNEUB"];
                dwLocal["WTGNEUD"] = dwInput["WTGNEUD"];

                dwLocal["WTGWBBRT"] = dwInput["WTGWBBRT"];
                dwLocal["WTGWBF"] = dwInput["WTGWBF"];
                dwLocal["WTGFDISM"] = dwInput["WTGFDISM"];
                dwLocal["WTGFDLGS"] = dwInput["WTGFDLGS"];
                dwLocal["WTGFDLFS"] = dwInput["WTGFDLGS"];
                dwLocal["WTGSMTRS"] = dwInput["WTGSMTRS"];
                #endregion

                #region==========INSERT========================
                if (!flgExist)
                {
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "INSERT INTO WTGEW(WTGMANDANT, WTGKUNDNR, WTGWERK, WTGABT, WTGART, WTGVAR, WTGAENZL, WTGAENB, WTGAEND, WTGNEUB, WTGNEUD, WTGWBBRT, WTGWBF, WTGFDISM, WTGFDLGS, WTGFDLFS, WTGSFLG, WTGKCOL, WTGSMTRS, WTGREAPPI, WTGRNAME, WTGCHORE, WTGRDENS, WTGRDENSTM, WTGRDENSTP, WTGKARTEN, WTGPLATINEN, WTGNOPPEN, WTGANZRAPP, WTGRWRAPH, WTGRWRAPB, WTGRWRAPHFD, WTGRWRAPBFD, WTGPANELS, WTGSHEDS, WTGNFLRH, WTGNFLRA, WTGNFTOLM, WTGNFTOLP, WTGMFLRH, WTGMFLRA, WTGMFTOLM, WTGMFTOLP, WTGHFLRH, WTGHFLRA, WTGHFTOLM, WTGHFTOLP, WTGFILLER)"
                        + "VALUES (:WTGMANDANT, '00000000', '   ', '   ', :WTGART, :WTGVAR, 1, '        ', 0, '        ', 0, 0, 0, 0, 0, 0, 'A              ', '0', 0, '               ', '               ', '0', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '000', '0', 0, '   ', 0, 0, 0, '   ', 0, 0, 0, '   ', 0, 0, '                                                  ')";
                    or1.Parameters.Add("WTGMANDANT", OracleType.NVarChar).Value = dwLocal["WTGMANDANT"].ToString();
                    or1.Parameters.Add("WTGART", OracleType.NVarChar).Value = dwLocal["WTGART"].ToString();
                    or1.Parameters.Add("WTGVAR", OracleType.NVarChar).Value = dwLocal["WTGVAR"].ToString();
                    Connect2Proxy(or1);
                }
                #endregion

                #region==========UPDATE========================
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "UPDATE WTGEW SET WTGAENB=:WTGAENB,WTGAEND=:WTGAEND"
                    + ",WTGNEUB=:WTGNEUB,WTGNEUD=:WTGNEUD"
                     + ",WTGWBBRT=:WTGWBBRT,WTGWBF=:WTGWBF,WTGFDISM=:WTGFDISM,WTGFDLGS=:WTGFDLGS,WTGFDLFS=:WTGFDLFS,WTGSFLG=:WTGSFLG,WTGSMTRS=:WTGSMTRS"
                    + " WHERE  "
                    + "  WTGMANDANT=:WTGMANDANT AND WTGART=:WTGART AND WTGVAR=:WTGVAR";

                or1.Parameters.Add("WTGMANDANT", OracleType.NVarChar).Value = dwLocal["WTGMANDANT"].ToString();
                or1.Parameters.Add("WTGART", OracleType.NVarChar).Value = dwLocal["WTGART"].ToString();
                or1.Parameters.Add("WTGVAR", OracleType.NVarChar).Value = dwLocal["WTGVAR"].ToString();
                or1.Parameters.Add("WTGAENB", OracleType.NVarChar).Value = dwLocal["WTGAENB"].ToString();
                or1.Parameters.Add("WTGAEND", OracleType.NVarChar).Value = dwLocal["WTGAEND"].ToString();
                or1.Parameters.Add("WTGNEUB", OracleType.NVarChar).Value = dwLocal["WTGNEUB"].ToString();
                or1.Parameters.Add("WTGNEUD", OracleType.DateTime).Value = dwLocal["WTGNEUD"].ToString();

                or1.Parameters.Add("WTGWBBRT", OracleType.NVarChar).Value = dwLocal["WTGWBBRT"].ToString();
                or1.Parameters.Add("WTGWBF", OracleType.NVarChar).Value = dwLocal["WTGWBF"].ToString();
                or1.Parameters.Add("WTGFDISM", OracleType.NVarChar).Value = dwLocal["WTGFDISM"].ToString();
                or1.Parameters.Add("WTGFDLGS", OracleType.NVarChar).Value = dwLocal["WTGFDLGS"].ToString();
                or1.Parameters.Add("WTGFDLFS", OracleType.NVarChar).Value = dwLocal["WTGFDLFS"].ToString();
                or1.Parameters.Add("WTGSFLG", OracleType.NVarChar).Value = dwLocal["WTGSFLG"].ToString();

                or1.Parameters.Add("WTGSMTRS", OracleType.NVarChar).Value = dwLocal["WTGSMTRS"].ToString();

                setResult = Connect2Proxy(or1);
                #endregion
                #region==========SELECT========================
                /*
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT *FROM WTGEW WHERE   "
                + "  WTGMANDANT=:WTGMANDANT AND WTGART=:WTGART AND WTGVAR=:WTGVAR";
                or1.Parameters.Add("WTGMANDANT", OracleType.NVarChar).Value = dwInput["WTGMANDANT"].ToString();
                or1.Parameters.Add("WTGART", OracleType.NVarChar).Value = dwInput["WTGART"].ToString();
                or1.Parameters.Add("WTGVAR", OracleType.NVarChar).Value = dwInput["WTGVAR"].ToString();
                setResult = Connect2Proxy(or1);
                if (setResult.Tables.Count > 0)
                {
                    tbLocal = setResult.Tables[0];
                    tbLocal.TableName = "WTGEW";
                }   */
                #endregion
                set4Return.Merge(setResult);

            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return set4Return;
        }

        public void InsertWABIND(string WABIND)
        {
            DataSet set4Return = new DataSet();
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            OracleCommand or1 = OracleDB.CreateCommand();
            bool flgExist = false;
            try
            {
                #region==========SELECT========================
                or1 = OracleDB.CreateCommand();
                string SDKEY = "00" + Left(WABIND + "                       ", 21) + "V";
                or1.CommandText = " SELECT * "
                + " FROM SDDAT WHERE SDSA='0109' AND SDKEY =:SDKEY";
                or1.Parameters.Add("SDKEY", OracleType.NVarChar).Value = SDKEY;

                setResult = Connect2Proxy(or1);
                if (setResult.Tables[0].Rows.Count > 0)
                {
                    return;
                }
                #endregion

                #region==========INSERT========================
                string SDDATEN = "A" + Left(WABIND + "                                                                                                    ", 40)
                + "          " + Left(WABIND + "                                      ", 10)
                + "00000100                                                                                  "
                + UserID + iDate + "0003*";
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "INSERT INTO SDDAT(SDSA,SDKEY,SDDATEN)"
                    + "VALUES ('0109',:SDKEY, :SDDATEN)";
                or1.Parameters.Add("SDKEY", OracleType.NVarChar).Value = SDKEY;
                or1.Parameters.Add("SDDATEN", OracleType.NVarChar).Value = SDDATEN;
                Connect2Proxy(or1);
                #endregion
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        public void InsertWTPASS(string WSPPASS)
        {
            DataSet set4Return = new DataSet();
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            OracleCommand or1 = OracleDB.CreateCommand();
            bool flgExist = false;
            try
            {
                #region==========SELECT========================
                or1 = OracleDB.CreateCommand();

                or1.CommandText = " SELECT *  FROM WTPASS "
                + "  WHERE WTPMANDANT='00' AND WTPPASSNR =:WTPPASSNR";
                or1.Parameters.Add("WTPPASSNR", OracleType.NVarChar).Value = WSPPASS;

                setResult = Connect2Proxy(or1);
                if (setResult.Tables[0].Rows.Count > 0)
                {
                    return;
                }
                #endregion

                #region==========INSERT========================

                or1 = OracleDB.CreateCommand();
                or1.CommandText = "INSERT INTO WTPASS(WTPMANDANT, WTPPASSNR, WTPSTAKZ, WTPBEZ, WTPEZ, WTPERSFD, WTPPSCHT, WTPLSCHTW, WTPLSCHTK, WTPGSCHT, WTPANZK, WTPRAPP, WTPGLITY, WTPGLATY, WTPGLARH, WTPGLAANZ, WTPPLITY, WTPPLATY, WTPPLARH, WTPPLAANZ, WTPAENDZL, WTPAENDBEN, WTPAENDDAT, WTPNEUBEN, WTPNEUDAT, WTPFILLER)"
                    + "VALUES ('00', :WSPPASS, 'A',:WTPBEZ, ' ', 0, 0, 0, 0, 0, 0, 0, '   ', '   ', 0, 0, '   ', '   ', 0, 0 , 0, '        ', 0, :WTPNEUBEN, :WTPNEUDAT, '                             ')";
                or1.Parameters.Add("WSPPASS", OracleType.NVarChar).Value = WSPPASS;
                or1.Parameters.Add("WTPBEZ", OracleType.NVarChar).Value = Left(WSPPASS + "                         ", 30);
                or1.Parameters.Add("WTPNEUBEN", OracleType.NVarChar).Value = UserID;
                or1.Parameters.Add("WTPNEUDAT", OracleType.NVarChar).Value = iDate;
                Connect2Proxy(or1);
                #endregion
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        public void UpdateWTPASS(DataRow dwWTPASS)
        {
            DataSet set4Return = new DataSet();
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            OracleCommand or1 = OracleDB.CreateCommand();
            bool flgExist = false;
            try
            {

                #region==========INSERT========================

                or1 = OracleDB.CreateCommand();
                or1.CommandText = "UPDATE  WTPASS SET WTPBEZ=:WTPBEZ"
                    + "  WHERE WTPPASSNR=:WTPPASSNR"
                    ;
                or1.Parameters.Add("WTPPASSNR", OracleType.NVarChar).Value = dwWTPASS["WTPPASSNR"];
                or1.Parameters.Add("WTPBEZ", OracleType.NVarChar).Value = dwWTPASS["WTPBEZ"];
                Connect2Proxy(or1);
                #endregion
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        public DataSet InsertWASTPASS(DataRow dwInput)
        {
            DataSet set4Return = new DataSet();
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            OracleCommand or1 = OracleDB.CreateCommand();
            bool flgExist = false;
            try
            {
                #region =============SELECT==============
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT *FROM WASTPASS WHERE   "
                + "  WSPMANDANT=:WSPMANDANT AND WSPART=:WSPART AND WSPVAR=:WSPVAR";
                or1.Parameters.Add("WSPMANDANT", OracleType.NVarChar).Value = dwInput["WSPMANDANT"].ToString();
                or1.Parameters.Add("WSPART", OracleType.NVarChar).Value = dwInput["WSPART"].ToString();
                or1.Parameters.Add("WSPVAR", OracleType.NVarChar).Value = dwInput["WSPVAR"].ToString();

                setResult = Connect2Proxy(or1);
                if (setResult.Tables.Count > 0)
                {
                    tbLocal = setResult.Tables[0];
                    tbLocal.TableName = "WASTPASS";
                    if (tbLocal.Rows.Count > 0)
                    {
                        or1 = OracleDB.CreateCommand();
                        or1.CommandText = "DELETE FROM WASTPASS WHERE   "
                        + "  WSPMANDANT=:WSPMANDANT AND WSPART=:WSPART AND WSPVAR=:WSPVAR";
                        or1.Parameters.Add("WSPMANDANT", OracleType.NVarChar).Value = dwInput["WSPMANDANT"].ToString();
                        or1.Parameters.Add("WSPART", OracleType.NVarChar).Value = dwInput["WSPART"].ToString();
                        or1.Parameters.Add("WSPVAR", OracleType.NVarChar).Value = dwInput["WSPVAR"].ToString();
                        Connect2Proxy(or1);
                    }
                }
                #endregion

                #region =============MAP==============
                if (dwLocal == null)
                {
                    dwLocal = setINTEX.WASTPASS.NewWASTPASSRow();
                }
                dwLocal["WSPMANDANT"] = dwInput["WSPMANDANT"].ToString();
                dwLocal["WSPART"] = dwInput["WSPART"].ToString();
                dwLocal["WSPVAR"] = dwInput["WSPVAR"].ToString();
                dwLocal["WSPPOS"] = dwInput["WSPPOS"].ToString();
                dwLocal["WSPPASS"] = Left(dwInput["WSPPASS"].ToString() + "                                         ", 15);

                #endregion

                #region =============INSERT==============

                or1 = OracleDB.CreateCommand();
                or1.CommandText = " INSERT INTO WASTPASS(WSPMANDANT, WSPKUNDNR, WSPWERK, WSPABT, WSPART, WSPVAR, WSPPOS, WSPPASS)"
                    + "VALUES (:WSPMANDANT, '00000000', '   ', '   ', :WSPART, :WSPVAR, :WSPPOS,:WSPPASS)";

                or1.Parameters.Add("WSPMANDANT", OracleType.NVarChar).Value = dwLocal["WSPMANDANT"].ToString();
                or1.Parameters.Add("WSPART", OracleType.NVarChar).Value = dwLocal["WSPART"].ToString();
                or1.Parameters.Add("WSPVAR", OracleType.NVarChar).Value = dwLocal["WSPVAR"].ToString();
                or1.Parameters.Add("WSPPOS", OracleType.Number).Value = dwLocal["WSPPOS"].ToString();
                or1.Parameters.Add("WSPPASS", OracleType.NVarChar).Value = dwLocal["WSPPASS"].ToString();
                Connect2Proxy(or1);

                #endregion

                #region =============LOAD==============
                /*
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT *FROM WASTPASS WHERE   "
                + "  WSPMANDANT=:WSPMANDANT AND WSPART=:WSPART AND WSPVAR=:WSPVAR";
                or1.Parameters.Add("WSPMANDANT", OracleType.NVarChar).Value = dwInput["WSPMANDANT"].ToString();
                or1.Parameters.Add("WSPART", OracleType.NVarChar).Value = dwInput["WSPART"].ToString();
                or1.Parameters.Add("WSPVAR", OracleType.NVarChar).Value = dwInput["WSPVAR"].ToString();
                setResult = Connect2Proxy(or1);
                if (setResult.Tables.Count > 0)
                {
                    tbLocal = setResult.Tables[0];
                    tbLocal.TableName = "WASTPASS";
                }*/
                #endregion
                set4Return.Merge(setResult);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return set4Return;
        }
        public DataSet InsertWAFARBEN(DataTable tbWAFARBEN)
        {
            DataSet set4Return = new DataSet();
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            OracleCommand or1 = OracleDB.CreateCommand();
            bool flgExist = false;
            DataRow dwWAFARBEN = tbWAFARBEN.Rows[0];
            try
            {
                #region =============SELECT==============

                or1 = OracleDB.CreateCommand();

                or1.CommandText = "SELECT *FROM WAFARBEN WHERE   "
                + "  WAFMANDANT=:WAFMANDANT AND WAFART=:WAFART AND WAFVAR=:WAFVAR";
                or1.Parameters.Add("WAFMANDANT", OracleType.NVarChar).Value = dwWAFARBEN["WAFMANDANT"].ToString();
                or1.Parameters.Add("WAFART", OracleType.NVarChar).Value = dwWAFARBEN["WAFART"].ToString();
                or1.Parameters.Add("WAFVAR", OracleType.NVarChar).Value = dwWAFARBEN["WAFVAR"].ToString();

                setResult = Connect2Proxy(or1);
                if (setResult.Tables.Count > 0)
                {
                    tbLocal = setResult.Tables[0];
                    tbLocal.TableName = "WAFARBEN";
                    if (tbLocal.Rows.Count > 0)
                    {
                        or1 = OracleDB.CreateCommand();
                        or1.CommandText = "DELETE FROM WAFARBEN WHERE   "
                            + "  WAFMANDANT=:WAFMANDANT AND WAFART=:WAFART AND WAFVAR=:WAFVAR";
                        or1.Parameters.Add("WAFMANDANT", OracleType.NVarChar).Value = dwWAFARBEN["WAFMANDANT"].ToString();
                        or1.Parameters.Add("WAFART", OracleType.NVarChar).Value = dwWAFARBEN["WAFART"].ToString();
                        or1.Parameters.Add("WAFVAR", OracleType.NVarChar).Value = dwWAFARBEN["WAFVAR"].ToString();
                        Connect2Proxy(or1);
                    }
                }


                #endregion
                dwLocal = setINTEX.WAFARBEN.NewWAFARBENRow();
                foreach (DataRow dwTemp in tbWAFARBEN.Rows)
                {
                    #region =============MAP=================
                    dwLocal["WAFMANDANT"] = dwTemp["WAFMANDANT"].ToString();
                    dwLocal["WAFART"] = dwTemp["WAFART"].ToString();
                    dwLocal["WAFVAR"] = dwTemp["WAFVAR"].ToString();
                    dwLocal["WAFZUART"] = dwTemp["WAFZUART"].ToString();
                    dwLocal["WAFZUSATZ"] = Left(dwTemp["WAFZUSATZ"].ToString() + "                      ", 10);
                    dwLocal["WAFBEZ"] = Left(dwTemp["WAFBEZ"].ToString() + "                      ", 20);
                    dwLocal["WAFNEUBEN"] = dwTemp["WAFNEUBEN"].ToString();
                    dwLocal["WAFNEUDAT"] = dwTemp["WAFNEUDAT"].ToString();
                    dwLocal["WAFAENDBEN"] = dwTemp["WAFAENDBEN"].ToString();
                    dwLocal["WAFAENDDAT"] = dwTemp["WAFAENDDAT"].ToString();
                    #endregion

                    #region =============INSERT==============
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "INSERT INTO WAFARBEN(WAFMANDANT, WAFKUNDNR, WAFWERK, WAFABT, WAFART, WAFVAR, WAFZUART, WAFZUSATZ, WAFCOLORIT, WAFSTATUS, WAFSFKZ, WAFBEZ, WAFTEXTSCHL, WAFFKARTNR, WAFROHFARBE, WAFMUDESS, WAFUNIFARB, WAFVGRQM, WAFVOLU, WAFZTWAHL, WAFRAPPH, WAFRAPPB, WAFRUESTGRP, WAFPRUEFGRP, WAFSCHABANZ, WAFUSCHABANZ, WAFFDVF, WAFPRGRP, WAFGRPBEZ, WAFPREIS, WAFZUABPR, WAFZUABAB, WAFNFART, WAFWERT, WAFKZPA, WAFZUABVH, WAFZUABAK, WAFZUABKU, WAFZUABPROZ, WAFEZUSTAND1, WAFEZUSTAND2, WAFEZUSTAND3, WAFEZUSTAND4, WAFEZUSTAND5, WAFEZUSTAND6, WAFEZUSTAND7, WAFEZUSTAND8, WAFEZUSTAND9, WAFEZUSTAND10, WAFFA, WAFGA, WAFQA, WAFQPKTH, WAFQPKTLH, WAFLOAN, WAFLBAN, WAFLPAN, WAFABKZAN, WAFPKL, WAFVBBRT, WAFBRTTOLPL, WAFBRTTOLMI, WAFVBGRQM, WAFVBGRLFD, WAFGWTOLPL, WAFGWTOLMIN, WAFVBFDDIK, WAFFDKTOLPL, WAFFDKTOLMI, WAFVBFDDIS, WAFFDSTOLPL, WAFFDSTOLMI, WAFLAEAEND, WAFGWVERL, WAFRESTSCHL, WAFPHWERTMI, WAFPHWERTMA, WAFWEISSGRD, WAFNETZFVON, WAFNETZFBIS, WAFNETZFSEK, WAFRSSFTRKV, WAFRSSFTRKB, WAFRSSFTRSV, WAFRSSFTRSB, WAFUNIFAEH, WAFFADGERAD, WAFMUSTFRB, WAFVORB, WAFNACHB, WAFMU, WAFMURLOD, WAFMUPROD, WAFMUCTOD, WAFMUDTRL, WAFMUBIRL, WAFHUNGLFM, WAFHUNGQM, WAFHUNBRT, WAFHUNFDK, WAFHUNFDS, WAFLMANRKRS, WAFLMALFDNR, WAFLMAPOS, WAFLODKRS, WAFLODLFD, WAFLODPOS, WAFKZDUMCOL, WAFPSEUDOCOL, WAFPRFSCHL, WAFFILLER, WAFAENDZL, WAFAENDBEN, WAFAENDDAT, WAFNEUBEN, WAFNEUDAT)"
                        + "VALUES (:WAFMANDANT, '00000000', '   ', '   ',:WAFART,:WAFVAR, :WAFZUART,:WAFZUSATZ, '          ', 'A', 'N', :WAFBEZ"
                    + ", '          ', '          ', '          ', '          ', '          ', 0, 0, 0, 0, 0, '   ', ' ', 0, 0, '   ', ' ', '                    ', 0, 0, 0, '    ', 0, ' ', 0, 0, 0, ' ', '    ', '    ', '    ', '    ', '    ', '    ', '    ', '    '"
                    + ", '    ', '    ', 0, 0, 0, 0, 0, '  ', '  ', '        ', ' ', '  ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ' ', ' ', '          ', '   ', '   ', ' ', '00', '00', ' '"
                    + ", 0, '        ', ' ', ' ', ' ', ' ', ' ', '  ', '    ', '  ', '  ', '      ', '   ', ' ', '          ', '         ', '                                                           ', 0, '        ', 0, :WAFNEUBEN, :WAFNEUDAT)";
                    or1.Parameters.Add("WAFMANDANT", OracleType.NVarChar).Value = dwLocal["WAFMANDANT"].ToString();
                    or1.Parameters.Add("WAFART", OracleType.NVarChar).Value = dwLocal["WAFART"].ToString();
                    or1.Parameters.Add("WAFVAR", OracleType.NVarChar).Value = dwLocal["WAFVAR"].ToString();
                    or1.Parameters.Add("WAFZUART", OracleType.NVarChar).Value = dwLocal["WAFZUART"].ToString();
                    or1.Parameters.Add("WAFZUSATZ", OracleType.NVarChar).Value = dwLocal["WAFZUSATZ"].ToString();
                    or1.Parameters.Add("WAFBEZ", OracleType.NVarChar).Value = dwLocal["WAFBEZ"].ToString();
                    or1.Parameters.Add("WAFNEUBEN", OracleType.NVarChar).Value = dwLocal["WAFNEUBEN"].ToString();
                    or1.Parameters.Add("WAFNEUDAT", OracleType.Number).Value = dwLocal["WAFNEUDAT"].ToString();
                    Connect2Proxy(or1);
                    #endregion
                }
                set4Return.Merge(setResult);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return set4Return;
        }

        public DataSet UpdateVA0710(DataTable tbWAFARBEN, DataRow dwWASTAMM, DataRow dwVAART, DataRow dwVAFARBEN, string color, string finish)
        {
            DataSet set4Return = new DataSet();
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            OracleCommand or1 = OracleDB.CreateCommand();
            DataRow dwWAFARBEN;
            string VAFFFARBE = "          ";
            string VAFBESCHICH = "          ";
            bool flgExist = false;
            try
            {
                #region=========UPDATE VA07======================
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "UPDATE VAART SET VAABESTANDF='J' ,VAADART=:VAADART,VAADVAR=:VAADVAR,VAALO='  ' ,VAADKUNDNR='00000000' WHERE   "
                + "  VAAMANDANT=:VAAMANDANT AND VAAKOLL=:VAAKOLL AND VAAART=:VAAART";
                or1.Parameters.Add("VAAMANDANT", OracleType.NVarChar).Value = dwVAART["VAAMANDANT"].ToString();
                or1.Parameters.Add("VAAKOLL", OracleType.NVarChar).Value = dwVAART["VAAKOLL"].ToString();
                or1.Parameters.Add("VAAART", OracleType.NVarChar).Value = dwVAART["VAAART"].ToString();
                or1.Parameters.Add("VAADART", OracleType.NVarChar).Value = dwWASTAMM["WADART"].ToString();
                or1.Parameters.Add("VAADVAR", OracleType.NVarChar).Value = dwWASTAMM["WADVAR"].ToString();
                setResult = Connect2Proxy(or1);

                /*
                var query = from dwTemp in tbWAFARBEN.AsEnumerable()
                            where dwTemp["WAFZUART"].ToString() == "C"
                            select dwTemp;
                foreach (DataRow dwTemp in query)
                {
                    VAFFFARBE = dwTemp["WAFZUSATZ"].ToString();
                }
                var query1 = from dwTemp in tbWAFARBEN.AsEnumerable()
                             where dwTemp["WAFZUART"].ToString() == "B"
                             select dwTemp;
                foreach (DataRow dwTemp in query1)
                {
                    VAFBESCHICH = dwTemp["WAFZUSATZ"].ToString();
                }
                */
                #endregion
                VAFFFARBE = color;
                VAFBESCHICH = finish;
                #region=========UPDATE VA10======================
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "UPDATE VAFARBEN SET VAFPART=:VAFPART,VAFPVAR=:VAFPVAR,VAFFFARBE=:VAFFFARBE,VAFBESCHICH=:VAFBESCHICH"
                    + " WHERE   "
                + "  VAFMANDANT=:VAFMANDANT AND VAFKOLL=:VAFKOLL AND VAFART=:VAFART AND VAFFARBE=:VAFFARBE";
                or1.Parameters.Add("VAFMANDANT", OracleType.NVarChar).Value = dwVAFARBEN["VAFMANDANT"].ToString();
                or1.Parameters.Add("VAFKOLL", OracleType.NVarChar).Value = dwVAFARBEN["VAFKOLL"].ToString();
                or1.Parameters.Add("VAFART", OracleType.NVarChar).Value = dwVAFARBEN["VAFART"].ToString();
                or1.Parameters.Add("VAFFARBE", OracleType.NVarChar).Value = dwVAFARBEN["VAFFARBE"].ToString();
                or1.Parameters.Add("VAFFFARBE", OracleType.NVarChar).Value = VAFFFARBE;
                or1.Parameters.Add("VAFBESCHICH", OracleType.NVarChar).Value = VAFBESCHICH;
                or1.Parameters.Add("VAFPART", OracleType.NVarChar).Value = dwWASTAMM["WADART"].ToString();
                or1.Parameters.Add("VAFPVAR", OracleType.NVarChar).Value = dwWASTAMM["WADVAR"].ToString();
                setResult = Connect2Proxy(or1);
                #endregion
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return set4Return;
        }
        public void UpdateWDECK(DataRow dwWDECK, DataRow dwWASTAMM)
        {
            OracleCommand or1 = OracleDB.CreateCommand();
            try
            {
                #region=========UPDATE WDECK======================
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "UPDATE WDECK SET WDART=:WDART,WDVAR=:WDVAR,WDPRART=:WDPRART,WDPRVAR=:WDPRVAR,WDKUNDNR='00000000'"

                    + " WHERE   "
                + "  WDMANDANT=:WDMANDANT AND WDAUFKRS=:WDAUFKRS AND WDAUFLFD=:WDAUFLFD AND WDAUFPOS=:WDAUFPOS AND WDUPOS=:WDUPOS ";
                or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwWDECK["WDMANDANT"].ToString();
                or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwWDECK["WDAUFKRS"].ToString();
                or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwWDECK["WDAUFLFD"].ToString();
                or1.Parameters.Add("WDAUFPOS", OracleType.NVarChar).Value = dwWDECK["WDAUFPOS"].ToString();
                or1.Parameters.Add("WDUPOS", OracleType.NVarChar).Value = dwWDECK["WDUPOS"].ToString();

                or1.Parameters.Add("WDART", OracleType.NVarChar).Value = dwWASTAMM["WADART"].ToString();
                or1.Parameters.Add("WDVAR", OracleType.NVarChar).Value = dwWASTAMM["WADVAR"].ToString();
                or1.Parameters.Add("WDPRART", OracleType.NVarChar).Value = dwWASTAMM["WAART"].ToString();
                or1.Parameters.Add("WDPRVAR", OracleType.NVarChar).Value = dwWASTAMM["WAVAR"].ToString();
                setResult = Connect2Proxy(or1);
                #endregion
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        public DataSet GetData(DataRow dwWAFARBEN, string color, string finish)
        {
            DataSet setReturn = new DataSet();
            DataSet setResult = new DataSet();
            string Article = (dwWAFARBEN["WAART"].ToString().Trim()
                + "/" + dwWAFARBEN["WAVAR"].ToString().Trim() + "/"
                + Convert8859P1ToGB2312(dwWAFARBEN["WAFZUSATZ"].ToString().Trim())).Trim();
            try
            {
                DataRow dwWASTAMM = null;
                setResult = GetRWS0305(dwWAFARBEN);

                EventDispatcher.Instance.RaiseStatus("品种" + Article + " 已读取GetRWS0305", StatusEventType.RunningProgress);
                dwWASTAMM = setResult.Tables["WASTAMM"].Rows[0];
                dwWAFARBEN["WAFART"] = dwWASTAMM["WAART"];
                dwWAFARBEN["WAFVAR"] = dwWASTAMM["WAVAR"];

                setResult = GetRWTGEW(dwWAFARBEN);

                setReturn.Merge(setResult);
                EventDispatcher.Instance.RaiseStatus("品种" + Article + " 已读取GetRWTGEW", StatusEventType.RunningProgress);


                setResult = GetRWASTPASS(dwWAFARBEN);

                setReturn.Merge(setResult);
                EventDispatcher.Instance.RaiseStatus("品种" + Article + " 已读取GetRWASTPASS", StatusEventType.RunningProgress);


                setResult = GetRWS07(dwWAFARBEN, "F", color);
                setReturn.Merge(setResult);
                setResult = GetRWS07(dwWAFARBEN, "B", finish);
                setReturn.Merge(setResult);

                EventDispatcher.Instance.RaiseStatus("品种" + Article + " 已读取GetRWS07", StatusEventType.RunningProgress);


                setResult = GetWS31(dwWAFARBEN);
                setReturn.Merge(setResult);
                EventDispatcher.Instance.RaiseStatus("品种" + Article + " 已读取GetWS31", StatusEventType.RunningProgress);


                setResult = GetWS33(dwWAFARBEN);
                setReturn.Merge(setResult);
                EventDispatcher.Instance.RaiseStatus("品种" + Article + " 已读取GetWS33", StatusEventType.RunningProgress);

            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        }
        #endregion
    }
}